Query build

L

Larry R. Baker

I am having trouble with structuring my query for searching using "LIKE". I
return no records with my current SQL statement. Any suggestions would be
appreciated.

Here is the string I am sending through ASP using VBScript as my language.

Other piece:
strClass = Request("SiteLOCCode")

String from ASP page:
"SELECT * FROM LDSWSNames WHERE WSName LIKE '" & strClass & "' "

Output string from ASP:
SELECT * FROM LDSWSNames WHERE WSName LIKE 'KYLEXAD01'
 
G

grw

You may want to use the wildcard (%) :

"SELECT * FROM LDSWSNames WHERE WSName LIKE '%" & strClass & "%'"

This will find all records containing *KYLEXAD01*

"SELECT * FROM LDSWSNames WHERE WSName LIKE '" & strClass & "%'"

This will find all records starting with KYLEXAD01*

"SELECT * FROM LDSWSNames WHERE WSName LIKE '%" & strClass & "'"

This will find all records ending with *KYLEXAD01
 
L

Larry R. Baker

Thanks, last night I totally blanked and could not remember the wildcard for
the end "%' and it worked great.

Again thanks to both of you.

Larry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top