如何在特定条件下选择mysql中的空字段?

时间:2017-12-01 13:41:41

标签: php mysql mysqli

我在mysql中有这个表

id |   chat_id   |   name  | grade | photo | phone
-------------------------------------------
1  |   1344564   |  mikel  |       |       |

所以我想在特定条件下在一个代码行中选择所有空字段(成绩,照片,电话)

3 个答案:

答案 0 :(得分:0)

您可以在查询中更新成绩,照片和手机,如下所示:

AND (grade = "" OR grade IS NULL)

答案 1 :(得分:0)

您是否要求查询所有其他字段何时为空?像...

SELECT * FROM TABLE 
WHERE chat_id="1344564" AND 
(grade = "" OR grade IS NULL) AND 
(photo = "" OR photo IS NULL) AND 
(phone = "" OR phone IS NULL)

答案 2 :(得分:0)

SELECT * FROM exampletable WHERE成绩或照片或电话IN('');