Exact string queries using LIKE

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am attempting to do some exact string queries from C++, using ADO, to MS ACCESS. I have been unable to find much information concerning this. The text field in the ACCESS database is called "Data". It contains html text. A simple query in C++ looks like this

SELECT id FROM tblData WHERE (Data LIKE '%[!a-z]Happy Day[!a-z]%')

This works fine. It doesn't allow "Happy Daytime" "Happy Days" "Unhappy Day" etc. There is one glitch. If there is a carriage return between "Happy" and "Day", more than one space or both, it doesn't find the string. Is there any way around this. I usually test within ACCESS using a query like this

SELECT id FROM tblData WHERE (Data LIKE '*[!a-z]Happy Day[!a-z]*'

If I were to use a star as in "Happy*Day" then the words may not be consecutive. Any help would be much appreciated
Background: Application was created in VS 6.0 and has been converted to the .NET version but .NET capabilities are not being applied. The strings used in the searches come from a much larger set and the set is not static
 
What is wrong with:

SELECT id FROM tblData WHERE (Data LIKE '*Happy Day*')

--
--Roger Carlson
www.rogersaccesslibrary.com
Reply to: Roger dot Carlson at Spectrum-Health dot Org

B Kanyid said:
I am attempting to do some exact string queries from C++, using ADO, to MS
ACCESS. I have been unable to find much information concerning this. The
text field in the ACCESS database is called "Data". It contains html text.
A simple query in C++ looks like this:
SELECT id FROM tblData WHERE (Data LIKE '%[!a-z]Happy Day[!a-z]%')

This works fine. It doesn't allow "Happy Daytime" "Happy Days" "Unhappy
Day" etc. There is one glitch. If there is a carriage return between
"Happy" and "Day", more than one space or both, it doesn't find the string.
Is there any way around this. I usually test within ACCESS using a query
like this:
SELECT id FROM tblData WHERE (Data LIKE '*[!a-z]Happy Day[!a-z]*')

If I were to use a star as in "Happy*Day" then the words may not be
consecutive. Any help would be much appreciated.
Background: Application was created in VS 6.0 and has been converted to
the .NET version but .NET capabilities are not being applied. The strings
used in the searches come from a much larger set and the set is not static.
 
You would have to use multiple criteria to do this as far as I can see.

Search for Happy Space Day, Happy Space Space Day, Happy CR LF Day
 
Back
Top