从学生表中获取其enrolment_id为空的记录

时间:2013-01-15 06:35:33

标签: php sql database-design

enrolment_idstudent表中的外键,我希望得到那些尚未设置外键的学生。含义enrolment_id = NULL(但这在WHERE子句中不起作用。)

怎么办?

2 个答案:

答案 0 :(得分:3)

比较NULL值时,请改用IS NULL谓词:

...
WHERE enrolment_ID IS NULL;

= NULL无效。

答案 1 :(得分:0)

SELECT * FROM student AS s WHERE s.enrolment_ID IS NULL;