Re: Select non-matching fields

2004-08-06 Thread Matt Warden
> I believe that when the query engine executes your statement, for each > row of purchased_items data it looks at, it will have to run the query > "SELECT ticket_number FROM purchases" scan those results and > determine if the current row matches. If it is in the list then it wil exclude > tha

Re: Select non-matching fields

2004-08-06 Thread Emmett Bishop
You're making the assumption that he's using 4.1.x. He didn't state which version he's using so your solution may be of no use to him. -- T --- Matt Warden <[EMAIL PROTECTED]> wrote: > On Fri, 06 Aug 2004 13:17:42 -0400, Michael Stassen > <[EMAIL PROTECTED]> wrote: > > You need a LEFT JOIN: > >

Re: Select non-matching fields

2004-08-06 Thread SGreen
Matt, I humbly beg to differ. I believe that what you wrote will be executed as a correlated subquery. That would make your statement much slower than a JOIN (especially if the correct indexes exist). I believe that when the query engine executes your statement, for each row of purchased_items

Re: Select non-matching fields

2004-08-06 Thread Matt Warden
On Fri, 06 Aug 2004 13:17:42 -0400, Michael Stassen <[EMAIL PROTECTED]> wrote: > You need a LEFT JOIN: > >SELECT ticket_number >FROM purchased_items LEFT JOIN purchases >ON purchased_items.ticket_number = purchases.ticket_number >WHERE purchases.ticket_number IS NULL; No, actuall

Re: Select non-matching fields

2004-08-06 Thread Michael Stassen
You need a LEFT JOIN: SELECT ticket_number FROM purchased_items LEFT JOIN purchases ON purchased_items.ticket_number = purchases.ticket_number WHERE purchases.ticket_number IS NULL; Michael Rob Best wrote: This is probably a very easy question for many of you. I have two tables, 'Purchases'

Select non-matching fields

2004-08-06 Thread Rob Best
This is probably a very easy question for many of you. I have two tables, 'Purchases' and 'Purchased_Items'. For every purchase there is one entry in 'Purchases' and 1 or more entries on 'Purchased_Items' (depending on how many items were purchased'. The two tables are linked by a 'ticket_number'