This question already has answers here:
How do I check if a column is empty or null in MySQL?
                                
                                    (18个回答)
                                
                        
                                6个月前关闭。
            
                    
我正在创建一个表,我想在其中显示一栏为空的数据。

我尝试了一切,但似乎无济于事

$sql = "SELECT * from tblleaves where empid=:eid and EndKm is NULL order by PostingDate desc";


换句话说,我想获取endkm列为空或仅包含空格的数据。

如果我删除EndKm为NULL,则对我来说一切正常。

最佳答案

尝试SELECT * from tblleaves where empid=:eid and (EndKm IS NULL or TRIM(EndKm) = '') order by PostingDate desc

07-27 20:24