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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying 2 tables

Status
Not open for further replies.

mot98

MIS
Jan 25, 2002
647
CA
I am trying to query 2 different tables with ASP pages. In the first table the data I am trying to get is a customer name, but when I reference that it the second table, the customers are reffered to as numbers. How do I go about linking the alpha name with the numeric number?

TIA for any help.

mot98..[peace]

"Where's the beer?"
 
you need to have the same number in both tables...
table1
custID number
custname name
custaddr address...

table2
orderID
CustID
productID

then the SQL is

select a.*, b.* from table1 a, table2 b where a.custID = b.custID

hth
Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
I am populating the first page with a drop down menu that shows all customers in the first table. I then need to reference those customers in the second table with another drop down box.

My code for the first drop down box looks like this...
<%
Do While NOT oRSa.EOF
Response.Write &quot;<OPTION VALUE='&quot; & oRSa(&quot;CustomerName&quot;) & &quot;'>&quot;
Response.Write oRSa(&quot;VendorName&quot;) & &quot;</OPTION>&quot;
oRSa.MoveNext
Loop
oRSa.Close
Set oRSa=Nothing
%>


In the second table, the CustomerName is changed to CustomerID, whish is now a number. So how do I link the two?

TIA for any help


mot98..[peace]

&quot;Where's the beer?&quot;
 
mot98 -

The way you have it written, each option's value is oRSa(&quot;CustomerName&quot;). Whatever that is, number or text, that is the value you will be passing to the next table. So the user is going to see oRSa(&quot;VendorName&quot;) click on it and pass the value oRSa(&quot;CustomerName&quot;).
Don't think that will work.

You need to remember that the value is just that, the value being passed. I would imagine that instead of
Response.Write &quot;<OPTION VALUE='&quot; & oRSa(&quot;CustomerName&quot;) & &quot;'>&quot; you would probably want Response.Write &quot;<OPTION VALUE='&quot; & oRSa(&quot;VendorID&quot;) & &quot;'>&quot;
 
Sorry about that the code should read as follows...

<%
Do While NOT oRSa.EOF
Response.Write &quot;<OPTION VALUE='&quot; & oRSa(&quot;CustomerName&quot;) & &quot;'>&quot;
Response.Write oRSa(&quot;CustomerName&quot;) & &quot;</OPTION>&quot;
oRSa.MoveNext
Loop
oRSa.Close
Set oRSa=Nothing
%>


There is another value in the table called CustomerID. Now I don't need that value on my first page, but I do on my second. How do I get that value on the first page, without showing it, and then pass it on to my next page?

Thanks for all your help...



mot98..[peace]

&quot;Where's the beer?&quot;
 
Put CustomerID in the value portion of the option in plac e of the CustomerName. I show you below:

<%
Do While NOT oRSa.EOF
Response.Write &quot;<OPTION VALUE='&quot; & oRSa(&quot;CustomerID&quot;) & &quot;'>&quot;
Response.Write oRSa(&quot;CustomerName&quot;) & &quot;</OPTION>&quot;
oRSa.MoveNext
Loop
oRSa.Close
Set oRSa=Nothing
%>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top