Problems using like for a title search

B

Bill

I'm trying to pull up all the titles in our database that have a word
like the one submitted from our search form.

The string is like this:


title=request.form("title")

sql=" SELECT * FROM books where title like '"&%title%&"' ORDER BY
title "

If I run a search straight in sql server using the %title% with the
percent signs before and after the variable name title, it will
dutiflly return all the titles that contain that word. However, when I
run the above string in asp, I get an error. Note I have '"&%title%&"'
That's quite a lot wrapped around it. I've tried a few variations of
this, but keep getting error messages. How do I do an approximate
search this way?

Thanks,

Bill
 
M

Manohar Kamath [MVP]

Try this:

sql=" SELECT * FROM books where title like '%"& title "%' ORDER BY title "
 
D

dlbjr

strSQL = " SELECT * FROM books WHERE title LIKE %" & title & "% ORDER BY
title "

dlbjr

Unambit from meager knowledge of inane others,
engender uncharted sagacity.
 

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

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,220
Latest member
AugustinaJ

Latest Threads

Top