Mark Bakelaar
asked on
sql like excluding
Hi Experts.
I use the following like statement lower(tekst) like '%est%' that gives me also some results I would like to exclude:
- EST D/A Alexandria V 22
- D/A Brest v 86 oppgj
How can I best approach this?
Best regards,
MB
I use the following like statement lower(tekst) like '%est%' that gives me also some results I would like to exclude:
- EST D/A Alexandria V 22
- D/A Brest v 86 oppgj
How can I best approach this?
Best regards,
MB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
By the way, if you are really just after excluding the two results, then "matthewspatrick" answer is sufficient.
By the way, if you are really just after excluding the two results, then "matthewspatrick" answer is sufficient.
ASKER
Hi Alfred1, I was just writing the following comment.
Hi matthewspatrick,
The example given might have been somewhat to simple in a way that I would like to exclude everything that has the word "Brest" in it, I would like to only get the abbreviation EST.
Hi matthewspatrick,
The example given might have been somewhat to simple in a way that I would like to exclude everything that has the word "Brest" in it, I would like to only get the abbreviation EST.
Hi,
Can I just confirm, you are just after EST or est?
You could do it this way if est only and not EST:
WHERE tekst like '% est %' COLLATE Latin1_General_BIN
or,
You could do it this way if EST only
WHERE tekst like '% EST %' COLLATE Latin1_General_BIN
Can I just confirm, you are just after EST or est?
You could do it this way if est only and not EST:
WHERE tekst like '% est %' COLLATE Latin1_General_BIN
or,
You could do it this way if EST only
WHERE tekst like '% EST %' COLLATE Latin1_General_BIN
Use another like statement for your examples. If there are any other commonalities, try to include those as well to not get unexpected results.
small modification to matthewspatrick's ...
WHERE lower(tekst) like '%est%' AND tekst NOT LIKE '%EST%' AND tekst NOT LIKE '%Brest%'
small modification to matthewspatrick's ...
WHERE lower(tekst) like '%est%' AND tekst NOT LIKE '%EST%' AND tekst NOT LIKE '%Brest%'
Hi,
Aha. Ok. you want Br of Brest out of the picture. You could do it this way.
WHERE tekst like '% EST %' COLLATE Latin1_General_BIN
AND tekst not like 'Br%' COLLATE Latin1_General_BIN
Aha. Ok. you want Br of Brest out of the picture. You could do it this way.
WHERE tekst like '% EST %' COLLATE Latin1_General_BIN
AND tekst not like 'Br%' COLLATE Latin1_General_BIN
ASKER
Sorry for the late reply, thanks for the help.
Try using binary collation. Try the following:
WHERE tekst like '%est%' COLLATE Latin1_General_BIN
I hope it helps.