2016-01-25 28 views
-2

所以我有2個表,有以下欄目:檢查,如果數據在另一個表具有項

-Sellers(名稱,用戶ID)

- 產品(姓名,身份證,sellerid)

因此,Seller表中的用戶標識與Products表中的sellerid相同。

現在我需要創建一個查詢來返回哪些賣家沒有在產品表中創建產品。

你能幫我嗎?

感謝

+0

的[SQL可能的複製 - 查找記錄從一個表哪些不存在於另一個](http://stackoverflow.com/questions/367863/sql-find-records-from-one-table-which-dont-exist-in-another) – showdev

回答

0

要得到誰沒有產品的所有賣家,我們得到的產品表中的所有ID,並使用「NOT IN」

Select ('name', 'userid') from Sellers Where 'userid' NOT IN (Select 'sellerid' from Products) 
相關問題