ORACLE JOIN TABLES
本问题已经有最佳答案,请猛点这里访问。
我有
1 2 3 4 5 6 7 | T1: USER_ID OSX 1 Y 2 Y T2: USER_ID ANDROID 1 Y 3 Y |
我想加入下表,但不知道怎么加入
1 2 3 4 | T3: USER_ID ANDROID OSX 1 Y Y 2 NULL Y 3 Y NULL |
你想要一个
1 2 3 4 5 | SELECT COALESCE(t1.user_id, t2.user_id) AS user_id, t2.android, t1.osx FROM t1 FULL JOIN t2 ON t1.user_id = t2.user_id; |
使用
1 2 3 4 5 | SELECT COALESCE(t1.user_id, t2.user_id) AS user_id, COALESCE(t2.android,'N/A') AS android, COALESCE(t1.osx,'N/A') AS osx FROM t1 FULL JOIN t2 ON t1.user_id = t2.user_id |