Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP + Recordsets + SQL

Status
Not open for further replies.

cwadams

Technical User
Apr 9, 2007
26
US
I am a newbie to ASP and am trying to learn.

In my ASP page I have 2 SQL Select Statements.
I am passing a value (4+)that is stored in my (SubRs "Class")recordset to the 2nd SQL statement, but I want to extract only the first character and then add a wildcard. So that I can extract all (4%)"Class 4-, 4, and 4+) Can I do that on the fly or do I need to extract the value and assign it to a variable first to run a function on it?
----------------------------------------------
<%
Dim objConn, SubRs, FirstPullRs
Set objConn = GetConnection()
Set SubRs = Server.CreateObject("ADODB.Recordset")
Set FirstPullRs = Server.CreateObject("ADODB.Recordset")
Set objFSO = Server.CreateObject ("Scripting.FileSystemObject")

subSQL = "SELECT Class, FROM VIEW_TABLE WHERE PROPID = '" & Request("propid") & "'"
SubRs.Open subSQL, objConn,1,1

FirstPullSQL = "SELECT PropId,Class FROM VIEW_TABLE WHERE PROPID <> '" & SubRs("PropId") & "' and Class like '" & SubRs(LEFT("Class",1,"%"))& "'"
FirstPullRs.Open FirstPullSQL, objConn,1,1
%>
 
Code:
FirstPullSQL = "SELECT PropId,Class FROM VIEW_TABLE WHERE PROPID <> '" & SubRs("PropId") & "'  and Class like '" & [!]Left(SubRs("Class"),1)[/!] & "%' "
    FirstPullRs.Open FirstPullSQL, objConn,1,1

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Code:
FirstPullSQL = "SELECT PropId,Class FROM VIEW_TABLE WHERE PROPID <> '" & SubRs("PropId") & "'  and Class like '%" & SubRs(LEFT("Class",1))& "%'"

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top