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'
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?
The NOT LIKE operator in SQL is used on a column which is of type varchar . Usually, it is used with % which is used to represent any string value, including the null character \0 .
If != and <> both are the same, which one should be used in SQL queries? Here is the answer – You can use either != or <> both in your queries as both technically same but I prefer to use <> as that is SQL-92 standard.
We can use both SQL Not Equal operators <> and != to do inequality test between two expressions. Both operators give the same output. The only difference is that '<>' is in line with the ISO standard while '!=
If WPP.COMMENT
contains NULL
, the condition will not match.
This query:
SELECT 1 WHERE NULL NOT LIKE '%test%'
will return nothing.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With