SQL statement

L

L

I would like to incorporate a serach page on my web site. I would like
for the user to be able to search on a company name and list all the
companys that start with "i" if the user types in "i". I know that I need
to add a wildcard character but unsure of the syntax.
Here's the code below:
strsql= "SELECT * FROM tblCompany where CompanyName LIKE '"&strSearch&"'"

Thanks.
 
J

Jens Peter Karlsen [FP-MVP]

The % goes last. As you wrote it, it will return any records with "i"
somewhere in them not just those that start with "i".

Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.

SELECT * FROM tblCompany WHERE CompanyName LIKE '%" & strSearch & "'"

Download SQL Server Books Online [1].

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://www.microsoft.com/sql/techinfo/productdoc/2000/books.mspx


L said:
I would like to incorporate a serach page on my web site. I would like
for the user to be able to search on a company name and list all the
companys that start with "i" if the user types in "i". I know that I need
to add a wildcard character but unsure of the syntax.
Here's the code below:
strsql= "SELECT * FROM tblCompany where CompanyName LIKE '"&strSearch&"'"

Thanks.
 

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

Top