Итак, я хочу получить все позиции SSC и получить количество позиций, которые еще не заняты.Однако я как-то застрял в предложении where.
Вот мои структуры таблиц:




А вот и мой запрос
SELECT p.position_id, a.account_id
FROM positions p
LEFT JOIN ssc s ON s.position_id = p.position_id AND s.removed = 0
LEFT JOIN students stud ON stud.students_id = s.students_id
LEFT JOIN accounts a ON a.account_id = stud.account_id
WHERE p.user_level_id = 6
AND p.removed = 0
Фактический результат таков:

Ожидаемый результат для отображения только тех полей, которые имеют значение NULL в account_id.Однако, если я включу AND a.account_id = NULL
в запрос, результат будет пустым.И если я когда-нибудь изменю запрос на:
SELECT p.position_id, a.account_id
FROM positions p
LEFT JOIN ssc s ON s.position_id = p.position_id AND s.removed = 0
LEFT JOIN students stud ON stud.students_id = s.students_id
LEFT JOIN accounts a ON a.account_id = stud.account_id AND a.account_id = NULL
WHERE p.user_level_id = 6
AND p.removed = 0
, тогда весь идентификатор учетной записи станет NULL