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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Joining 4 tables

Author  Topic 

batgrrrl
Starting Member

8 Posts

Posted - 2001-11-05 : 20:09:34
Hi Guys,

Am after just a touch of help with some joins.

Tables
Lines - (pk header_id, po_line_num)
Header - (pk header_id)
Invoices - (pk invoice_id - fk header_id)
InvoiceLines - (pk invoice_id, invoice_line_num)

Basically I want everything from the Lines table (that equals a set criteria)
I want the records in the Header table that match the Lines.header_id
I want the records in the Invoices table that match the Lines.header_id
I want the records in the InvoiceLines table that match the Invoices.invoice_id

What sort of joins should i use here. I've tried some basic ones but end up with 70 000 records when I should only end up with 3.

I can get it working by selecting from the Lines table, then joining the Header table. But I dont know the right way to join the Invoices and InvoiceLines tables properly.

If anyone can steer me in the right direction I would be very thankful :)

Thanks for reading this

Renee :)

   

- Advertisement -