mysql查询问题:'like'没有按预期工作

时间:2015-11-06 17:55:07

标签: mysql

我正在尝试选择'cats'列不包含字符串'people-and-activities'的行。字符串'cats'可以是'',NULL或非空值。

select ref from images where (url like 'parks%')  and ((not (cats like '%people-and-activities%')));
10634 rows in set

之前的回复不正确。这个似乎是正确的。

 select ref,caption,cats from images where (url like 'parks%')  and  (cats like '%people-and-activities%') ; 
 647 rows in set 

我不明白的是,数字并没有加起来:

 select ref,caption,cats from images where (url like 'parks%');
 13600 rows in set

 select ref,caption,cats from images where (url like 'parks%')  and ((not (cats like '%people-and-activities%')) or (cats like '%people-and-activities%')) ;
 11281 rows in set

有人可以向我解释这个谜吗?感谢

0 个答案:

没有答案