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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query using "Like" is giving me some problems

Status
Not open for further replies.

pparadis

MIS
Dec 5, 2000
22
0
0
US
I have an sql query used to search for projects that match a users input string. The query works when I take it out of the code and try it in Access, but it wont work when trying to run it from my page. Anybody know why it would do this? Thanks. Here is the SQL:
strSQL = "Select * From Projects Where
ProjTitle Like '*"&Request.QueryString("ProjectTitle")&"*'
AND ProjDescription Like '*"&Request.QueryString
("Description")&"*' AND ProjStatus = '"&Request.QueryString
("status")&"'"



 
Try

strSQL = "Select * From Projects Where ProjTitle Like " & Request.QueryString("ProjectTitle") & " AND ProjDescription Like " & Request.QueryString("Description") & " AND ProjStatus = " & Request.QueryString("status") Live long and make your kids suffer..
 
the wildcard when using LIKE is the percent sign (%), not the asterisk (*). try:

strSQL = "Select * From Projects Where ProjTitle Like '%" & Request.QueryString("ProjectTitle") & "%' AND ProjDescription Like '%" & Request.QueryString("Description") & "%' AND ProjStatus = '" & Request.QueryString("status") & "'"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top