且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL Full Out Join在同一表的同一列上

更新时间:2022-12-11 19:40:59

您首先做错了事,然后尝试对其进行修复.那是行不通的.

You're doing the wrong thing first, and attempting to fix it up afterwards. That's not going to work.

您要加入的内容是select * from stuff where grp = 'a'select * from stuff where grp = 'b'.因此,加入这些人:

The things you want to join are select * from stuff where grp = 'a' and select * from stuff where grp = 'b'. So join those:

select a.ID as a, b.ID as b from
  (select * from stuff where grp = 'a') a
full join
  (select * from stuff where grp = 'b') b
on b.id = a.id

SQL提琴