This topic is locked

Check if table DOES NOT include a value

1/26/2008 9:55:39 AM
PHPRunner General questions
F
Fawaz author

Order table contains: ID and Status....

Invoice table contains: ID, Order_ID,...
I'm trying to create Custom View for Order table:

SELECT ID FROM Order WHERE Status='Confirmed' AND Invoice table doesn't include Order_ID


This query gives: All orders confirmed but no invoice is issued for each of them.
My question is: How do I write Invoice table doesn't include Order_ID in the SQL query?
Thanks,

Fawaz

F
Fawaz author 1/26/2008

Is it possible in the SQL editor?

J
Jane 1/28/2008

Fawaz,
here is a sample:

SELECT ID FROM Order WHERE Status='Confirmed' AND ID not in (select Order_ID from Invoice)


Please note subqueries are supported in the MySQL 4.1 and later.