Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Database Query 1

Status
Not open for further replies.

simoncpage

Programmer
Apr 4, 2002
256
0
0
GB
Hi all, I am trying to work out how to search a string with sql to see if it contains a smaller string. For instance I wish to search to see if "dis" is contained in one of the fields in the access database description column. (and I would like to find entries like discontinued, disks, etc)

The idea I had was to search all the strings and split each search string into 3 parts ... so the string "Hello Test" would be split into

Hel
ell
llo
lo

...
etc

comparing each one to see if it equal the initial query "dis"

using the sql

strSELECT = "SELECT * FROM stock WHERE Ref = '" & txtRef.Text & "' "

where ref = search string (dis) and txtref will be the spliting up of the description string.

But I think that for large databases this will be a slow query..is there a quicker/easier way?

Any help would be appreciated!

Thanks

Simon
 
Hi,

here is the query:
strSELECT = "SELECT * FROM stock WHERE Ref like "'*" & txtRef.Text & "*' "
If it does not work, replace * to % (there is sometimes a problem with it in RDO.

 
Thanks great I thought there would be a simpler way!
 
In general use the '*' wildcard for Access databases and '%' for SQL databases and ADO queries on Access

There's some good stuff on wildcards in VBHelp and SQLBOL
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top