SELECT ques_id,ans_desc
FROM answer
ORDER BY ans_desc
HAVING ans_desc=0
3 回答
2
在子句中使用ans_desc IS NULL谓词WHERE:
SELECT ques_id, ans_desc
FROM answer
WHERE ans_desc = 0 OR ans_desc IS NULL
ORDER BY ans_desc ;
这将只为您提供列中包含0或NULL值的那些ans_desc。
独自一WHERE ans_desc = 0人不会给出NULL价值。
于 2013-03-20T07:46:49.057 回答
0
当您只需要选择具有 NULL 值的行时,我认为您甚至不需要“按 ans_desc 排序”。
您应该执行以下操作:
SELECT ques_id as `question`, ans_desc as `answer`
FROM answer
WHERE ans_desc is NULL;
此查询的优点是它不使用文件排序。
有关您正在使用的查询,请参阅解释的输出以了解更多信息。
希望有帮助。
于 2013-03-20T08:00:13.323 回答
0
0不同于NULL和不同于空
SELECT ques_id,ans_desc
FROM answer
WHERE ISNULL(ans_desc) OR ans_desc = ''
ORDER BY ans_desc
于 2013-03-20T07:50:38.433 回答