Unanswered: Selecting where join condition not equal true
I'm trying to write some SQL that queries a mySQL database against two relational tables.
Consider two classic database tables: tblProducts and tblOrderLines
I would like to query the database for all products in the tblProducts table that are NOT on a particular order in the tblOrderLines table in a single query.
This is for a web application so i want as few round trips to the database as possible. I'm quite capable of doing it in multiple queries and a bit of business logic in ASP but i'd rather keep it clean in a single database query.
I had planned on showing you my workings so far but to be quite honest i've not got close yet
r937 - thank you so much.
I don't know why I cant get my head round SQL, it just doesn't logically fit in my brain.
If you happen to find yourself with a spare 5 mins and feel like taking pity on this n00b an explanation of that query would be greatly appreciated.
I always thought I understood the different join types but it's become obvious... i don't
Well from reading up on a LEFT OUTER JOIN i have to conclude that i was right in my understanding of them before, i just never knew that you could put in other join conditions other than linking two fields together (and OL.order_id = 937 for example)
I've never used outer joins in that way before, I just immediately set about this task assuming that somwhere would be some form of OL.Order_id NOT LIKE 937 involved, never thought about using a test for null instead.