mysql union选择table1 field3 = table2 field5的位置

时间:2017-03-07 01:17:41

标签: mysql select union

我从mysql开始,我不知道如何解决这样的问题:

SELECT 
  table1.col1 AS A,
  table1.col3 As B
UNION
  table2.col2 AS C,
  table2.col5 AS D
WHERE
  table1.col4 = table2.col6

/*expected*/
A B C D

1 个答案:

答案 0 :(得分:1)

为什么不说:

SELECT 
  table1.col1 AS A,
  table1.col3 As B,
  table2.col2 AS C,
  table2.col5 AS D
FROM TABLE1
INNER JOIN Table2 on TABLE2.col6=TABLE1.col4