gpt4 book ai didi

php - MySQL多表连接

转载 作者:太空宇宙 更新时间:2023-11-03 12:00:43 24 4
gpt4 key购买 nike

post_info 表包含与单个 ID 匹配的许多行(多边)。我无法在输出中返回多行。

enter image description here

SELECT user.*, post.*, post_info.*, board.* FROM user 
join post ON user.id = post.user_id
join post_info ON post.id = post_info.post_id
WHERE user.id = 26;

我也不确定如何将我的 board 表写入查询。

用户表:

enter image description here

post_info 表:

enter image description here

张贴表:

enter image description here

最佳答案

这就是将板表写入查询的方式。添加了额外的加入以代表董事会发布关系。

SELECT user.*, post.*, post_info.*, board.* FROM user 
join post ON user.id = post.user_id
join post_info ON post.id = post_info.post_id
join board ON board.id = post.board_id
WHERE user.id = 26;

关于php - MySQL多表连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29291029/

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