Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Query Construct- 1

Status
Not open for further replies.

Dashley

Programmer
Dec 5, 2002
925
US
I have two tables. ISBN is unique Table1 (orders has 8829 rows). table2 (best_sellers) has top 100 best sellers.

Table1 (Orders) Table2(best_Sellers)
ID ID
(pk)ISBN (pk)ISBN
Price Price


I'm trying to find out which ISBN's in the best_sellers table have never had an order.
Many of the ISBN's in the order table are not in the best seller table.
End result I'm trying to produce a list of best sellers that have never been ordered.

Thanks
 
Best Sellers: BS
Orders: Ord

[tt]Select BS.*
from BS
left join Ord
on Ord.ISBN = BS.ISBN
where Ord.ISBN is null[/tt]
 
Another method

Select * from best_Sellers
minus
Select * from Orders

 
Thank you both for responding.

denimined yours did just what I needed. The "where Ord.ISBN is null" is the piece of the puzzle I didn't think to do and would probably never think to do. I will in the future :)

xxxing yours returned two listing but it wasnt the lists I was looking for. I do thank you for responding.
I read-up on the minus function which I had never seen before . Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top