Reputation: 11
I have 3 table that need to join but I want to show all on query
first table : itemtable
id itemname
1 item1
2 item2
second table : priceleveltable
id levelname
1 level1
2 level2
third table : relationtable
id itemid itemlevel price
and I want to show all record based on itemtable
and priceleveltable
become like this :
itemname pricelevel price
item1 level1 null
item1 level2 null
item2 level1 null
item2 level2 null
Can I query like that? I have tried left,right,inner join but it doesn't display record if no record on relation table
Upvotes: 0
Views: 1384
Reputation: 3626
You would have to use a full outer join
on Table3 and the join result on the first and second table.
SELECT * from firstTable as ft
INNER JOIN secondTable as st
ON ft.id = st.id
FULL OUTER JOIN thirdTable as tt
ON ft.id = tt.id
WHERE ft.id IS NOT NULL
Upvotes: 1