List:General Discussion« Previous MessageNext Message »
From:Thimble Smith Date:September 24 1999 2:44am
Subject:Re: A Query
View as plain text  
At 22:39, 19990923, Chris Lambrou wrote:
>Hello, I need to get records in table a that don't exist in b

You want to use the left join trick.

mysql> select b.shopper_id
    -> from   sale_items b left join sales a
    ->        on (a.shopper_id = b.shopper_id)
    -> where  a.shopper_id is null;

That will find any sales that are not paired with a sale_item.

>mysql> select b.shopper_id
>    -> from   sale_items b, sales a
>    -> where  b.shopper_id <> a.shopper_id;

I'm sure that's not doing what you'd like.  That's pretty much returning
a full join of the two tables, less a few rows....

A QueryChris Lambrou24 Sep
  • Re: A QueryThimble Smith24 Sep
    • Re: A QueryThimble Smith24 Sep
  • Re: A QueryAndrian Pervazov24 Sep