SQL - find records from one table which don't exist in another

后端 未结 8 874
生来不讨喜
生来不讨喜 2020-11-21 22:44

I\'ve got the following two SQL tables (in MySQL):

Phone_book
+----+------+--------------+
| id | name | phone_number |
+----+------+--------------+
| 1  | J         


        
8条回答
  •  伪装坚强ぢ
    2020-11-21 23:00

    SELECT DISTINCT Call.id 
    FROM Call 
    LEFT OUTER JOIN Phone_book USING (id) 
    WHERE Phone_book.id IS NULL
    

    This will return the extra id-s that are missing in your Phone_book table.

提交回复
热议问题