I have this a SQL Server table Users
with a column codename
with a lot of records, example:
...
[LP]Luis
JoseLuis
[LP]Pedroso
Luis
PedroLuis
[LP]Maria
CarlosJose
MariaJose
[LP]Carlos
Pedro
...
I need to make a query for a search form that ignore all codename
s that contain [LP]
I wrote and run the following query:
SELECT TOP (15)*
FROM [Users]
WHERE [codename] LIKE '%Luis%'
AND [codename] NOT LIKE '%[LP]%'
This query doesn't return anything.
I want to get (In this example) the records:
Luis
PedroLuis
JoseLuis
If I query:
SELECT TOP (15) *
FROM [Users]
WHERE [codename] LIKE '%Luis%'
I get:
[LP]Luis
JoseLuis
Luis
PedroLuis
and if I add to the query:
AND [codename] NOT LIKE '%[LP]%'
I get nothing.