我想运行此查询:
SELECT col1 , col2 , table1.*
FROM
(SELECT table2.col1 as col1 , table2.col2 as col2 , table1.* FROM table1 INNER JOIN table2 ...
UNION
SELECT table3.col1 as col1 , table2.col2 as col2 , table1.* FROM table1 INNER JOIN table2 ...
)order by table1.col1
但我无法运行它,因为我应该用table1的列名替换(SELECT col1,col2,table1。*)处的table1。*。
您需要为联合查询指定别名。
就像是:
SELECT col1 , col2 , talias.*
FROM
(SELECT table2.col1 as col1 , table2.col2 as col2 , table1.* FROM table1 INNER JOIN table2 ...
UNION
SELECT table3.col1 as col1 , table2.col2 as col2 , table1.* FROM table1 INNER JOIN table2 ...
) as talias order by talias.col1
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句