gpt4 book ai didi

mysql - 连接来自两个不同表 MySQL 的所有行

转载 作者:太空宇宙 更新时间:2023-11-03 11:02:19 25 4
gpt4 key购买 nike

我一直在尝试连接两个不同表中的所有行。我试过 UNION 和 LEFT JOIN。

现在我一直在使用两个单独的查询,一个接一个地显示。我想合并两个查询以同时显示。

表 1 称为“批准”,表 2 称为“评论”。

approves
- id
- postID
- postUserID
- userID

comments
- id
- postID
- postUserID
- userID
- comment
- date

最佳答案

这里是一个 UNION 的例子

select id, postID, postUserID, userID, comment, date from comments
union
select id, postID, postUserID, userID, null, null from approves

关于mysql - 连接来自两个不同表 MySQL 的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14735851/

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