I do not understand why following code does not work?
SELECT [column1], [column2]
FROM table where Column1 <> ('%TEST%')
ORDER BY 1
I want to have all rows where Colu开发者_StackOverflow社区mn1 does not contain TEST
Thanks
Use LIKE operator with Wildcards %:
SELECT [column1], [column2]
FROM table
WHERE Column1 NOT LIKE ('%TEST%')
ORDER BY 1
If you want to use wildcards you have to use the LIKE operator:
SELECT [column1], [column2]
FROM table where Column1 NOT LIKE '%TEST%'
ORDER BY 1
Wildcards (%
) in SQL should be used in conjunction with the LIKE
operator:
SELECT [column1], [column2]
FROM table where Column1 NOT LIKE ('%TEST%')
ORDER BY 1
try
SELECT [column1], [column2]
FROM table where Column1 NOT LIKE '%TEST%'
ORDER BY 1
% is a wildcard expression, which is probably the reason why; I think you may, if you want a literal %, wrap it in square braces [%], but I actually forget if that is the answer, and apologize if it isn't.
If you want to use it as where the column doesn't have the text test in it, then you do:
where column1 not like '%Test%'
You need to say Column1 NOT LIKE '%TEST%'
.
Did you mean using like?
where Column1 not like '%TEST%'
精彩评论