如何检查MySQL列以确保它包含值?

时间:2009-06-10 04:10:39

标签: php mysql select null

我正在尝试从数据库中选择display ='Y'和announcement!= null的所有行。如何检查列以确保它包含值?

 $qry = "select *   
         from   school
     where  display='Y'
     order by name, announcement, last_update";

2 个答案:

答案 0 :(得分:4)

$qry = "select *       
         from   school
         where  display='Y'
         and (announcement != '' AND announcement IS NOT null)
         order by name, announcement, last_update";

这适用于空白字段和​​空字段。

答案 1 :(得分:3)

announcement IS NOT NULL

NOT ISNULL(announcement)