-2

So I have 2 tables, with the following columns:

-Sellers (name, userid)

-Products (name, id, sellerid)

So, the userid from Seller table is the same as the sellerid from Products table.

Now I need to create a query to return which are the sellers that have no product created at the products table.

Can you help me out?

Thanks

gqmonteiro
  • 37
  • 1
  • 7
  • Possible duplicate of [SQL - find records from one table which don't exist in another](http://stackoverflow.com/questions/367863/sql-find-records-from-one-table-which-dont-exist-in-another) – showdev Jan 25 '16 at 18:14

1 Answers1

0

To get all Sellers who have no product, we get all id in the product table, and use 'NOT IN'

Select ('name', 'userid') from Sellers Where 'userid' NOT IN (Select 'sellerid' from Products)
Decoded
  • 1,057
  • 13
  • 17