joining 3 tables
hi all
i was wonder if its possible to join 3 tables, so i could see the result from the 3 tables.
for example
lets say that i have
INVOICE(invoice_id, client_id,item_id)
CLIENTS(id, client_name)
ITEM(item_id, item_name)
i want 1 table that shows: invoice_id, client_name,item_name
is this possible?
10x!
severman
Junior Poster in Training
70 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
finito
Nearly a Posting Virtuoso
1,321 posts since May 2010
Reputation Points: 60
Solved Threads: 135
How your tables are linked to each other ?
I don't think they are.
debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
How your tables are linked to each other ?
I don't think they are.
INVOICE(invoice_id, client_id,item_id)
CLIENTS(id, client_name)
ITEM(item_id, item_name)
I think he/she will have to client_id with id on client and Invoice then union on ITEM.item_ID = INVOICE.Item_ID
finito
Nearly a Posting Virtuoso
1,321 posts since May 2010
Reputation Points: 60
Solved Threads: 135
if it wasn't clear
INVOICE(invoice_id, client_id,item_id)
CLIENTS(client_id, client_name)
ITEM(item_id, item_name)
client_id in invoice is FK IN CLIENTS
item_id in INVOICE is FK in ITEMS
so they are linked
oh, and union will not work because union returns one field, not multiple fields
severman
Junior Poster in Training
70 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
THANKS FINITO
you're link was very helpful!
this is the code of joining 4 tables for any one here who might want to know the answer:
select invoice_title.id, clients.name,items.item_des, invoice_line.amount
from invoice_title, clients, invoice_line,items
where invoice_title.client_id=client_id and invoice_line.item_id=items.item_id and
invoice_title.id=invoice_line.id order by item_des;
severman
Junior Poster in Training
70 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
finito
Nearly a Posting Virtuoso
1,321 posts since May 2010
Reputation Points: 60
Solved Threads: 135