[thelist] Need a SQL pro

Richard Davey rdavey at gmail.com
Wed Aug 25 19:27:45 CDT 2004


On Wed, 25 Aug 2004 18:47:31 -0500, Chris Ditty <cditty at gmail.com> wrote:

> Hi All.  Hopefully a SQL pro here can help me out here.  I have 2
> tables and I want to pull information from one table (table 1) where
> the auctionID in not in the other table (table 2).

MySQL 4 will do this with a sub-select such as:

SELECT whatever FROM table1 WHERE auctionid NOT IN (SELECT auctionID
FROM table2);

Or you can do it with a LEFT JOIN (should work in MySQL 3):

SELECT table1.whatever FROM table1 LEFT JOIN table2 ON
table1.auctionid = table2.auctionid WHERE table2.auctionid IS NULL

Cheers,

Rich


More information about the thelist mailing list