0

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!

5
Contributors
9
Replies
11
Views
7 Years
Discussion Span
Last Post by mrahil2008
0

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

0

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

Edited by severman: n/a

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;
0

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

select i.invoice_id ,c.client_name,it.item_name
from invoice i, client_name c,item_name it
where (i.client_id = c.client_id) AND (i.item_id = it.item_id)

0

select i.invoice_id ,c.client_name,it.item_name
from invoice i, client_name c,item_name it
where (i.client_id = c.client_id) AND (i.item_id = it.item_id)

0

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!

i assumed tables are joined according to id's.
u try this query and reply me if done

>>create table abc(invoice_id,client_name,item_nane)
as select i.invoice_id,c.client_name,it.item_name
from invoice i,client c,item it
where
i.item_id = it.item_id and
i.client_id = c.client_id;

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.