This is a follow up question to my last question about table joins in MySQL
I need to be able to select the NULL values from the left joined table.
Here's my join:
table1.id | table1.name | table2.id | table2.surname
1 | John | 1 | Doe
2 | Michael | 2 | Anderson
3 | Anna | NULL | NULL
4 | Sue | NULL | NULL
I would want to select WHERE table2.surname = NULL
, but a query like this doesn't work:
SELECT table1.*,table2.*
FROM table1
LEFT JOIN table2
ON table1.id=table2.id
WHERE table2.surname=NULL
I can somewhat understand the logic behind it not giving me any results, but there must be a way to grab them results?
Appreciate any help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…