Forums

ASP

This topic is locked

recordset

Posted 13 Jun 2007 20:26:28
1
has voted
13 Jun 2007 20:26:28 Ben Mroczek posted:
Good afternoon,

I am having trouble translating the following and would appreciate any help you can offer.

Select AccountID, userfirstname, userlastname, useraccesslevel
from website users
where useraccesslevel = 2 AND userlastname LIKE 'varlastname%' AND userfirstname LIKE 'varfirstname%'

the last line baffles me. i understand the basics of recordsets and how to get the following to work:
where accountid = varuserid

adding the other items just isn't something i've done

Thank you in advanced

Replies

Replied 15 Jun 2007 18:15:07
15 Jun 2007 18:15:07 Seb Adlington replied:
Hi Ben,

You're looking at a SQL select statement to retrieve information from whatever flavour database you are using.

LIKE 'varlastname%' tells the system to pull back records that match varlastname and the % symbol is a wildcard character like *

So if in the DB you have records Fred, John, Peter, Pearce etc if your variable is "pe%" it will bring back peter & pearce.

If you are going to be doing much with databases I recommend you invest in a good book or some serioous google time!

Cheers

Seb
Replied 15 Jun 2007 18:29:45
15 Jun 2007 18:29:45 Ben Mroczek replied:
thank you. I did not trial and error work and came up with the solution...


sort of like this:

rsresults.Source = "Select AccountID, strFirst_Name, strLast_Name, Access_Level From website_users Where Access_Level = 2 AND strLast_Name LIKE '" + Replace(rsresults__varLast_Name, "'", "''" + "%' AND strFirst_Name LIKE '" + Replace(rsresults__varFirst_Name, "'", "''" + "%'"

Reply to this topic