您好我有3个表我想从3个表中提取相同的列这是更好的方法来编写选择查询。
3D - line
答案 0 :(得分:1)
不确定,但我认为你是在追求这样的事情......
select * from
(
select t1.col1, t2.id1 , t1.col3 from table1 t1
INNER JOIN testid1 t2 ON t1.name = t2.name
union all
select t1.coltab1, t2.newid2, t1.coltab3 from testid2 t1
INNER JOIN table2 t2 ON t1.name=t2.name
union all
select t1.namecol1, t2.id3, t1.namecol3 from testid3 t1
INNER JOIN table3 t2 ON t1.name=t2.name
) A