I have this really simple query. I am unable to figure out why my query is not returning null records.
SELECT table1.name, table2.name
FROM table
LEFT OUTER JOIN table2
ON table1.id = table2.id
WHERE table1.someid='2'
AND table2.someid=2
ORDER BY table1.order
I also tried using LEFT JOIN, JOIN, INNER JOIN, FULL OUTER JOIN gives an error.
This simple query returns all required values.
SELECT table1.name
FROM table
WHERE table1.someid='2'
ORDER BY table1.order
whatever you will put in the where clause will force the resultsets to return the rows from the affected table.
In your case you are asking for table2.someid=2, which for mysql means that table2 MUST return a row, with or without a left join.
Solution: use this filter within the left join instead of the where clause