Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Multiple Inner Joins

Author  Topic 

RichardSteele
Posting Yak Master

160 Posts

Posted - 2007-10-23 : 22:40:15
I have a customer table which has customer billing addresses; an orders table which has payment and shipping method info; and an items table which has line items for each order. The customer table has a custnum index field. The orders table has a custnum and orderid field. And the items table has an orderid field.

I'd like to be able to retrieve, in one query, the customer's billing address, all of their orders, with each of their order's line items.

What would the query look like in order to accomplish this?

Thanks in advance.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-23 : 22:45:31
[code]SELECT *
FROM customer c
INNER JOIN orders o ON o.custnum = c.custnum
INNER JOIN items i ON i.orderid = o.order_id [/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -