Note to those of you that have written me with words of appreciation and encouragement as well as suggestions for new pop quizzes: First: Thanks for the kind words! Second: If you’re awaiting an answer, please rest assured that I do read your mail! I get mails relating to the pop quizzes daily, so I’m having to work on this in batch mode. You will get an answer from me in a few days.
Today’s question comes from Bertrand Gorge, who tells me he uses this as a test question during interviews. So if you’re looking to work for him, make sure you’ve understood this!
The following two queries do not return the same result. Why ?
SELECT table1.* FROM table1 LEFT JOIN table2 ON table2.table1_id = table1.id AND table2.val < 5 SELECT table1.* FROM table1 LEFT JOIN table2 ON table2.table1_id = table1.id WHERE table2.val …[Read more]