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

How to display from opne table based on id

Status
Not open for further replies.

gmagerr

Technical User
Aug 11, 2001
323
0
0
US
I know the subject is a little confusing, i'm sorry about that. I have a couple of tables that are related. Products and Orders. i have a foreign key in the orders table from the Products Table (ProductID) ok i want to display things from the orders table in a table on an asp page, i can do this fine... here's the problem. there's a field in the Products table i want to display it's called manufacturers, how can i show the manufacturers name in the orders table based on the ProductID foreign key? make sense? for example i want to make a page and say here's all the porducts that were ordered from this manufacturer, and this one and this one... for this particular order. right now i am displaying just the ProductID number not the manufacturer name. So i want to replace the ProductID number with the corrosponding manufacturers name from the Products table. Jeeeezzzz i just gave myself a headache... Thanks in advance.
 
Looks like you need a JOIN statement:

SQL Sample:

SELECT o.orderID, o.orderDate, p.manufacturer
FROM Orders o
INNER JOIN Products
ON o.ProductID = p.ProductID
WHERE orderID = <order_ID>

I hope that is in the general vicinity of what you were looking for :)
<Dmitriy>
dbrom@crosswinds.net
 
SHOULD BE:

INNER JOIN Products p <Dmitriy>
dbrom@crosswinds.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top