[thelist] SQL replace subquery with join

r937 rudy at r937.com
Tue Jan 5 11:15:33 CST 2010


hi bill

try like this -- 

   SELECT cd.*
     FROM cd
   LEFT OUTER
     JOIN genre
       ON genre.cd = cd.id
      AND genre.name = 'rock'
    WHERE genre.name IS NULL

in the ON clause of the outer join, put what you're looking for (i.e. 
looking for rock)

then the WHERE clause filters those out, leaving only the ones that aren't 
rock

simple, innit

;o)


rudy
http://simply-sql.com/




More information about the thelist mailing list