How does this not work?


  • 0
    A
    select C.Name
    from Customers C, Orders O
    where C.Id<>O.CustomerId

  • 2
    N
    By default two tables will do cartesian product ( or so called inner join)  , for example :
    A
    id	name	password
    1	Tom	        123
    2	Merry	merryme
    
    B
    id	salary
    1	100
    2	200
    3	300
    
    select *  from  B ,A ; will get the following result:
    
    id	salary	id	name	password
    1	100	1	Tom	        123
    1	100	2	Merry	merryme
    2	200	1	Tom  	123
    2	200	2	Merry	merryme
    3	300	1	Tom	        123
    3	300	2	Merry	merryme
    
    after you remove the A.id<>B.id ,it's obviously different from what you expect !
    
     My answer is:
    

    select name from Customers where id not in(select CustomerId from Orders)


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.