嗨,我正在尝试合并两个表。
我的 id 只存在于左表中,我的 id 只存在于右表中。我想要一张包含所有 id 的表。我尝试过:
select * from temp_hours as a
left outer join temp_orders as o on a.proj_id = o.proj_id
union
select * from temp_hours as a
right outer join temp_orders as o on a.proj_id = o.proj_id
但我收到错误:
Can't reopen table: 'a'
我有什么想法可以做到这一点吗?服务器版本:5.0.51a-24+lenny4(Debian)
最佳答案
按照建议添加括号或更改缩写...
select * from temp_hours as a
left outer join temp_orders as ao on a.proj_id = ao.proj_id
union
select * from temp_hours as b
right outer join temp_orders as bo on b.proj_id = bo.proj_id
关于mysql 联合不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10716879/