Exact match when using LIKE
Posted on 2004-03-22
I am using MS SQL 2000 and would like to get the exact text values when doing a search. However when i use a LIKE it brings back more than i need.
For example some rows contain this and i want just 'the'
then i did this
the best one
there we go
the there then
then there the
This is the query i have come up with, is this the only way of doing it where i look for the combinations for the start, middle and end taking into account spaces. Seems very long winded.
select * from test
where test like 'the %' or test like '% the' or test like '% the %'