Forum Moderators: open

Message Too Old, No Replies

multiple joins?

         

noyearzero

4:35 pm on Oct 27, 2008 (gmt 0)

10+ Year Member



i'm creating a product manager with category, subcategory, thirdcateogry.

in the products table these will be numbers relating to a key in a category table. I can left join the category onto the products table, but then can i additonally join the subcategory and thirdcategory on products?

I'd really like to do so so i can sort properly by either subcategory or thirdcategory name and not just the id number.

Demaestro

7:43 pm on Oct 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes you can

select
tbl1.id
tbl2.id
tbl3.id
from
table1 tbl1 left join table2 tbl2 on tbl1.id = tbl2.id
left join table3 tbl3 on tbl2.id = tbl3.id
sort by
tbl2.id

noyearzero

3:29 am on Oct 28, 2008 (gmt 0)

10+ Year Member



hey thanks a bunch... it took me a while but i finally got it. i guess my biggest problem was that my table 2 and table 3 were the same table, so i had to alias them properly and this method works.