Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 2nd, 2003, 12:07 AM
Authorized User
 
Join Date: Sep 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zaeem Send a message via Yahoo to zaeem
Default Problem in the LIKE query

I am new to ASP I am using the query
<sqlQuery="Select * from journal where title LIKE ' " &search&" '">.But it is not working. Can anybody guide me in this regard. PLease also tell me where to insert Percentage(%)sign.
I am waiting for your quick response.
Bye

Zaeem Sherazi
__________________
Zaeem Sherazi
 
Old October 2nd, 2003, 02:21 AM
Registered User
 
Join Date: Sep 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

You need all the records thath contains "search" in the TITLE field

search = "ASP"
sql = "SELECT * FROM JOURNAL WHERE TITLE LIKE '%" & search & "%'"

( SELECT * FROM JOURNAL WHERE TITLE LIKE '%ASP%' )

Is this what wou need or I wrong?



 
Old October 2nd, 2003, 02:21 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

When you're a using LIKE, you'll need a wildcard as well. The LIKE you have now, finds just exact matches of search.

Try this:

sqlQuery = "SELECT * FROM journal WHERE title LIKE '%" & search & "%'"

This will find all records that contain search somewhere. If your results should start or end with search, remove one of the two % characters.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 2nd, 2003, 02:45 AM
Authorized User
 
Join Date: Sep 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zaeem Send a message via Yahoo to zaeem
Default

Thanks for ur aooperation but SEARC variable is not the static one, it is coming from other page and then on the basis of search I'll make the select query.

Zaeem Sherazi
 
Old October 2nd, 2003, 02:51 AM
Authorized User
 
Join Date: Sep 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zaeem Send a message via Yahoo to zaeem
Default

Hello Imar thanks for ur quick response. Your suggested solution is working very well.
Thanks again.
Bye

Zaeem Sherazi
 
Old October 2nd, 2003, 03:16 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think jorevil's solution does exactly the same as mine. All that was added was assigning a value to the search variable, so the code would run.

Since you only posted the SQL statement, it wasn't clear where search got its value from.....

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Query Problem. rupen Access 3 April 27th, 2007 07:43 AM
Query Problem bundersuk VB Databases Basics 0 December 30th, 2006 07:50 AM
problem with query harpua Classic ASP Databases 1 January 24th, 2005 12:36 PM
Problem in query leo_vinay Classic ASP Databases 5 January 21st, 2005 06:32 AM
query problem mateenmohd SQL Server 2000 7 September 9th, 2003 11:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.