如何使用SQL中的Join来获取Not Common
这是我的表A
+------+----------+
| id | contact |
+------+----------+
| 4 | 1111-111 |
| 5 | 2222-222 |
| 6 | 3333-333 |
| 7 | 4444-444 |
| 8 | 5555-555 |
+------+----------+
这是我的表B
+------+----------+
| id | Name |
+------+----------+
| 1 | Juan |
| 2 | Carlo |
| 3 | Mark |
| 4 | Joseph |
| 5 | May |
+------+----------+
这是我的查询=>从B内连接A中选择名称,其中B.id = A.id
+----------+
| Name |
+----------+
| Joseph |
| May |
+----------+
但我的预期输出应为:
+----------+
| Name |
+----------+
| Juan |
| Carlo |
| Mark |
+----------+
答案 0 :(得分:0)
使用left join
Select name
from B
left join A ON B.id = A.id
where A.id is null