gpt4 book ai didi

mysql - 是否可以使用 join 和 union 进行查询?

转载 作者:行者123 更新时间:2023-11-29 21:14:27 25 4
gpt4 key购买 nike

我想进行这样的查询...

select table1.col1, table1.col2, table1.col3 from table1 union
select table2col1, table1col2, table2col3 from table2
left join table2 on table1.col1 = table2.col1

我想要表2中的表1中的一些列,因为我知道表2中缺少一些我需要从表1中完成我使用连接的联合标准的列,但我也想要两个表的联合

如有任何建议,我们将不胜感激。

最佳答案

试试这个:

(select table1.col1, table1.col2, table1.col3 from table1 )
union
(select table2col1, table1col2, table2col3 from table2
left join table1 on table1.col1 = table2.col1)

关于mysql - 是否可以使用 join 和 union 进行查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36081693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com