我正在尝试从数据库中选择display ='Y'和announcement!= null的所有行。如何检查列以确保它包含值?
$qry = "select *
from school
where display='Y'
order by name, announcement, last_update";
答案 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)