[thelist] using SQL left join query and NULL to find records NOT in a table

Shashank Tripathi sub at shanx.com
Fri Feb 15 07:26:01 CST 2002


Ben, you could try including the newsletterid condition in your Join
clause. I haven't tried it, but it could be somewhat like this..


    select
          a.userid
          ,a.firstname
          ,a.email
          ,a.sendnewsletter
          ,b.newsletterid
    from
          USER a
    left join
          NEWSLETTER_SENT b
    on
          a.userid = b.userid
      and b.newsletterid = $n
    where
          b.userid is null


Hope this is useful.

Shashank




More information about the thelist mailing list