1
我想從數據庫中選擇display ='Y'和公告!= null的所有行。我如何檢查一列以確保它包含一個值?如何檢查MySQL列以確保它包含值?
$qry = "select *
from school
where display='Y'
order by name, announcement, last_update";
我想從數據庫中選擇display ='Y'和公告!= null的所有行。我如何檢查一列以確保它包含一個值?如何檢查MySQL列以確保它包含值?
$qry = "select *
from school
where display='Y'
order by name, announcement, last_update";
$qry = "select *
from school
where display='Y'
and (announcement != '' AND announcement IS NOT null)
order by name, announcement, last_update";
這迎合了空白領域以及空字段。
announcement IS NOT NULL
或
NOT ISNULL(announcement)
標準SQL的方式是包含NULL的任何聲明應該返回null,這就是爲什麼你必須使用IS NOT NULL或ISNULL() – nickf 2009-06-10 04:15:04