my first table is meeting
id | title | body |
---------------------------
1 | mytit | my message |
---------------------------
2 | anoth | another mes |
---------------------------
3 | title | again a mess |
my second table is Meeting_status and it has a foreign key from the meeting table and another table called teachers
status_id | teacher_id | meeting_id
-------------------------------------------
1 | 28 | 2
-------------------------------------------
my query is :
SELECT * FROM meeting LEFT JOIN meeting_status ON meeting.id = meeting_status.meeting_id WHERE meeting_status.teacher_id <> 28
what I want as result is to show only the rows where teacher_id 28 doesn't exist like:
id | title | body | status_id | teacher_id | meeting_id
-----------------------------------------------------------------------
1 | mytit | my message | NULL | NULL | NULL
-----------------------------------------------------------------------
3 | title | again a mess | NULL | NULL | NULL
I changed my query like:
SELECT *
FROM meeting
LEFT JOIN meeting_status ON meeting.id = meeting_status.meeting_id where(teacher_id IS NULL
OR teacher_id <> 28)
and it gave me the output I was expecting.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.