在单个查询中检索两个表 [英] retrieve two tables in a single query
问题描述
我必须检索两个在单个查询中没有任何关系的表
例如
select * from memberphoto; select * from restrictconfig;
如果我执行此查询只查看restrictconfig表但我希望在一个查询中同时检索两个表
advance谢谢
kirthika
如果你的表有兼容的结构你可以使用 UNION 子句。另请参阅结合查询
组合查询结果不是人们经常做的事情,其中一个原因是这很少被证明是合理的。
在执行此操作之前,请再次考虑并确保您没有解决应该在数据库设计或应用程序中的其他位置解决的某些问题。
< blockquote>
thanka michaelb
但是我想检索两个没有关系的表,第二个表的行数比第一个表多。我希望结果显示两个表分别显示两个表的行。
请有任何可行的方法。我可以在sqlserver中这样做,但我不能在这里做。如果有人知道请帮助我
提前感谢
kirthika
kirthika,please附加到现有线程而不是创建新线程。
如果您对使用此论坛有任何疑问,请查看发布指南位于论坛顶部。
kirthika,请附加到现有的帖子而不是新的。
如果您对使用此论坛有任何疑问,可以查看发布指南。
michaelb,请告诉我如何追加现有主题我无法理解
I have to retrieve two tables which are not having any relation in a single query itself
for example
select * from memberphoto;select * from restricconfig;
if i execute this query only restricconfig table is viewed but i want both table to be retrieved simultaneously in a single query
advance thanks
kirthika
If your tables have compatible structures you can use the UNION clause. Also see combining queries
Combining query results is not something people do very often, and one reason for that is that this is rarely justified.
Think again before you do this and make sure you are not working around some problem that should have been addressed either in database design, or somewhere else in the application.
thanka michaelb
but i want to retrieve two tables which has no relation and second table is having more rows than first one. and i want the result to show two tables displaying the rows of two tables separately.
pls is there any possible way. I can do this in sqlserver but i can''t do it here. if any one know pls help me
thanks in advance
kirthikakirthika, please append to existing thread rather than making a new one.
If you have any doubts about using this forum it may be helpful to review the Posting Guidelines at the top of the Forum.
kirthika, please append to existing thread rather than making a new one.
If you have any doubts about using this forum it may be helpful to review the Posting Guidelines at the top of the Forum.michaelb, please tell be how append to existing thread i can''t understand
这篇关于在单个查询中检索两个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!