选择在结果中包含NULL或空

时间:2013-07-29 09:36:14

标签: mysql sql null

我想在下面做一个选择,结果是NULL

查询在

下面
SELECT id, result
FROM  `fq_account_extend_result` 
WHERE id_extend =5
AND (
id =1
OR id =2
OR id =3
OR id =4
)
ORDER BY id ASC 

结果如下:

id  result
1   testtest
2   asdasd
3   bill

我想包含id_extend = 4,即使结果是空的

id  result
1   testtest
2   asdasd
3   bill
4 

2 个答案:

答案 0 :(得分:1)

SELECT id_extend, result

FROM fq_account_extend_result WHERE id = 5 AND id_extend IN(1,2,3,4) ORDER BY id ASC

答案 1 :(得分:1)

试试这个:

   SELECT id_extend, result
    FROM  fq_account_extend_result
    WHERE id =5 AND
    id_extend IN(1,2,3,4)
    OR result is null
    ORDER BY id ASC