I just got an email…
“Yes, I know about this problem. This is LEFT JOIN problem.”
Anyone care to guess what that particular problem may be? Super exotic problems. How cool is that?
…
OK. Here’s a hint from someone answering a similar question at a forum…
“This how it works: first you have a table specified with FROM. Then you get a new table (conceptually) by with JOIN. When you use a LEFT JOIN all rows in the left tables are included, and the columns from the right table as NULL.
Then you apply a WHERE clause on this table and filter rows with the conditions you have. With the condition on D.Dealer_code, all rows with NULL goes out the window.
This gives a couple of ways to fix this. The most common and probably the best is to move the condition on Dealer_code to the ON part.”
… to which the guy who asked the original question replies…
“Cool. Knew I’d missed something simple. Just having a bad day. Thanks !”
LOL. There was something simple in there?
It must be me, then.
That’s definitely database talk. It’s part of how you pull the data out of the tables and actually put it together to be used. I recently had some database problems myself because the code was a little messed up. It was a JOIN problem too.
“Get me a list of everyone on X mailing list that has not yet received Y email” is the type of problem which this style of query can answer:
SELECT * FROM users LEFT JOIN user_received_email ON ure_usid = us_id WHERE ure_id IS NULL AND ure_emailid = $email_id
We used to use this in an old company as an SQL test for potential new hires. Its a pretty useful one to know.
LOL. Hi Alex!
I did wonder if that blog post would bring you out of hiding.
How are things with you?
Neil.