Mysql查询5张表
我在谷歌上搜索了两个小时,但没有找到我认为简单的东西。我有 4 个表,我可以将下面的前 4 个表合并在一起,并且我拥有所有表中的所有行。我试图弄清楚如何添加 1 个额外的 FullName 列,以便所有结果在基于 b 的每一行中显示 table5 中的 FullName,而 b 位于所有其他表中。我希望这对某人有意义。
SELECT a, b, NULL AS Name FROM table1
union SELECT a, b, NULL AS Name FROM table2
union SELECT a, b, NULL AS Name FROM table3
union SELECT a, b, NULL AS Name FROM table4
union SELECT NULL AS a, b, FullName FROM table5 where
.....b 等于前面 4 个 select 语句中的任意 b
I have searched google for 2 hours and no luck on what I think is simple. I have 4 tables that I can union together the first 4 below and I have all the rows from all the tables. I am trying to figure out how I can add 1 extra column of FullName so that all the results show the FullName from table5 in every row based on b which is in all the other tables. I hope this makes sense to someone.
SELECT a, b, NULL AS Name FROM table1
union SELECT a, b, NULL AS Name FROM table2
union SELECT a, b, NULL AS Name FROM table3
union SELECT a, b, NULL AS Name FROM table4
union SELECT NULL AS a, b, FullName FROM table5 where
.....b is equal to any b in the previous 4 select statements
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能有用吗?
编辑:更新...
Might work?
EDIT: Updated...