Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Problem using LIKE operator with WHERE


Message #1 by major_paton@y... on Mon, 25 Nov 2002 05:29:43
> The =20 and =3D are an artifact of the e-mail list-server.  Remove them 
and
it should work.

Brian Freeman
(770) 916-0595 ext. 415
Carnegie Technologies/Bluewave Computing 
www.carnegie.com and www.bluewave-computing.com

-----Original Message-----
From: major_paton@y... [mailto:major_paton@y...]
Sent: Tuesday, November 26, 2002 11:29 AM
To: sql language
Subject: [sql_language] RE: Problem using LIKE operator with WHERE


> ' small change to protect from SQL injection
strSearch =3D Replace(Request.Form("searchstring"), "'", "''")

strQuery =3D "SELECT Category.CategoryName, " & _
	"Links.LinkName, Links.LinkURL " & _
	"FROM Links, Category " & _
	"WHERE Category.CategoryID =3D Links.CategoryID " & _=20
	"AND (Links.LinkName LIKE '%" & strSearch & "%' " & _
	"OR Category.CategoryName LIKE '%" & strSearch & "%' " & _=20
	"ORDER BY Category.CategoryName, Links.LinkName"


It is just about generating strings.

regards
David Cameron
nOw.b2b
dcameron@i...

David, Thank you for responding to my question. I tried the code above and 
got this error message: Microsoft VBScript compilation error '800a0401' 

Expected end of statement 

/uploads/d229850/Lesson6Search.asp, line 26 

strSearch =3D Replace(Request.Form("searchstring"), "'", "''")
-----------^

I'm pretty new to Sequel Query Language. What is the '3D' and also what 
function does the =20 at the end of the WHERE and OR lines perform? I 
appreciate any help you can offer.
Thanks,
Major Paton
major_paton@y...
---
Change your mail options at http://p2p.wrox.com/manager.asp or 
to unsubscribe send a blank email to


Brian, I removed the 3D and =20 from the lines in the query and am now 
getting this error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) 
in query expression 'Category.CategoryID =3D Links.CategoryID AND 
(Links.LinkName LIKE '%News%' OR Category.CategoryName LIKE '%News%')'. 

Here is my code:
strSearch = Replace(Request.Form("searchstring"), "'", "''")
strQuery = "SELECT Category.CategoryName, " & _
	"Links.LinkName, Links.LinkURL " & _
	"FROM Links, Category " & _
	"WHERE Category.CategoryID =3D Links.CategoryID " & _
	"AND (Links.LinkName LIKE '%" & strSearch & "%' " & _
	"OR Category.CategoryName LIKE '%" & strSearch & "%')" & _
	"ORDER BY Category.CategoryName, Links.LinkName"
Any ideas or suggestions?
Thanks Much,
Major

  Return to Index