我有三个表,共有四个列。我想要一个从这四列中检索数据的查询。例如,四个列是ID,名称,电子邮件,电话。我想从那四列中检索数据。
有人可以帮忙吗?
使用UNION:
select id, name, email, phone
from table1
union
select id, name, email, phone
from table2
union
select id, name, email, phone
from table3;
在上面的查询中,来自不同表的相同行将显示为一行。如果要所有表中的所有行,请使用UNION ALL。
使用INTERSECT在所有三个表中仅选择相同的行:
select id, name, email, phone
from table1
intersect
select id, name, email, phone
from table2
intersect
select id, name, email, phone
from table3;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句