SQL: How do you select only groups that do not contain a certain value?

后端 未结 3 728
野的像风
野的像风 2020-11-30 06:01

Say I have a table:

Restaurant locations: 

RESTAURANT_NO | RESTAURANT_LOCATION
-----------------------------------
1             |            City A
1               


        
3条回答
  •  余生分开走
    2020-11-30 06:30

    Use DISTINCT.

    try this:

    SELECT DISTINCT t.Restaurant_No
    FROM Restaurant t
    WHERE t.Restaurant_No NOT IN
           (SELECT s.Restaurant_No  
            FROM  Restaurant s
            WHERE s.RESTAURANT_LOCATION = 'City C')
    ORDER BY t.Restaurant_No
    

提交回复
热议问题