• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

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
0
mark_norge
Asked:
mark_norge
1 Solution
 
Patrick MatthewsCommented:
WHERE lower(tekst) like '%est%' AND tekst <> 'EST D/A Alexandria V 22' AND tekst <> 'D/A Brest v 86 oppgj'
0
 
Alfred A.Commented:
Hi,

Try using binary collation.  Try the following:

WHERE tekst like '%est%' COLLATE Latin1_General_BIN


I hope it helps.
0
 
Alfred A.Commented:
Hi,

By the way, if you are really just after excluding the two results, then "matthewspatrick" answer is sufficient.
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
mark_norgeAuthor Commented:
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.
0
 
Alfred A.Commented:
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
0
 
TyugCommented:
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%'
0
 
Alfred A.Commented:
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

0
 
mark_norgeAuthor Commented:
Sorry for the late reply, thanks for the help.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now