【问题标题】:Mysql return empty rows if multi where condition with empty value如果多重条件为空值,Mysql 返回空行
【发布时间】:2014-12-14 03:27:05
【问题描述】:

我以文件夹表的名称创建了表 它包含名称、FolderId、ParentFolderId 当我编写 where 查询时,它返回空行

Example 1 :
Query :
select * from folders_tbl where parentResourceId='' 

Result : 
As I Expected 

但我在其中添加了一些 where 条件,它将无法返回预期的行

Example 2 : (Issue)
QUERY :
SELECT *  FROM folders_tbl WHERE parentResourceId =  ''
AND serviceId =1
AND userId =1

Result : 
 returned an empty result set

Table Structure 

folderId    bigint(20)  
serviceId   int(11)     
userId  bigint(20)      
folderName  varchar(200)    
resourceId  varchar(500)    
parentResourceId    varchar
createdDate datetime    
modifiedDate    datetime    
Shared  int(11)         
isTrashed   int(11)     
isDeleted   int(11)        

Note : I write a query in phpMyAdmin web UI

【问题讨论】:

  • 你能分享你的数据吗?顺便说一句,这听起来好像 MySQL 正在按应有的方式行事。
  • 你有NULL值吗,检查parentResourceId是NULL的地方

标签: php mysql database phpmyadmin mysql-workbench


【解决方案1】:

您的记录似乎包含空值。如果是则使用

parentResourceId is null 在 where 条件下

【讨论】:

    猜你喜欢
    • 2013-11-26
    • 1970-01-01
    • 2019-08-03
    • 2014-01-18
    • 1970-01-01
    • 1970-01-01
    • 2020-08-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多