SQL Not Like 语句不起作用 [英] SQL Not Like Statement not working
问题描述
我在存储过程中有以下代码.
I have the following code within a stored procedure.
WHERE
WPP.ACCEPTED = 1 AND
WPI.EMAIL LIKE '%@MATH.UCLA.EDU%' AND
(WPP.SPEAKER = 0 OR
WPP.SPEAKER IS NULL) AND
WPP.COMMENT NOT LIKE '%CORE%' AND
WPP.PROGRAMCODE = 'cmaws3'
NOT LIKE 语句不起作用,是的,在任何人说任何话之前,COMMENT 列中的项目不包含 CORE,而所有其他列都可以.
The NOT LIKE statement is not working, and yes before anyone says anything there are items with the COMMENT column that does not include CORE and all the other columns are ok.
有人知道这是怎么回事吗?
Does anyone know what is wrong with this?
推荐答案
如果 WPP.COMMENT
包含 NULL
,条件将不匹配.
If WPP.COMMENT
contains NULL
, the condition will not match.
这个查询:
SELECT 1
WHERE NULL NOT LIKE '%test%'
不会返回任何东西.
在 NULL
列上,针对任何搜索字符串的 LIKE
和 NOT LIKE
都将返回 NULL
.
On a NULL
column, both LIKE
and NOT LIKE
against any search string will return NULL
.
能否请您发布您认为应该返回但实际上没有返回的行的相关值?
Could you please post relevant values of a row which in your opinion should be returned but it isn't?
这篇关于SQL Not Like 语句不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!