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
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,
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, actually he
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
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:
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
that row