PDA

View Full Version : Search Query


Vimal
05-30-2003, 12:00 AM
Hi ppl,

I have used the following query:

strSQL = "SELECT * from details where name LIKE '%" & request("namebox1") & "%' ORDER BY name"

What I wanted to do was to obtain all the names in my database that BEGIN with the particular letter typed in the searchbox.

However, what I am getting is all the names that contain that particular letter, no matter its position in the name.

Can anyone give me the exact code for such a query plz.

Thank you

Regards,
Vimal

amir
05-30-2003, 07:19 AM
The following SQL statement will return persons with first names that end with an 'a':

SELECT * FROM Persons
WHERE FirstName LIKE '%a'

The following SQL statement will return persons with first names that start with an 'O':

SELECT * FROM Persons
WHERE FirstName LIKE 'O%'


taken from :

W3scool (http://www.w3schools.com/sql/sql_where.asp)

ansar
06-02-2003, 05:14 AM
" select * from table where fname like ' "&request("name1")&" %' "

Vimal
06-02-2003, 05:33 AM
Thank you..I got the code, and it works out perfectly. :)