Q:

Join 3 tables without losing ability to refer each table

I have 3 tables with this mock data
Item *id, name*
1, coke
2, fanta 
3, juice

Branch *id, name*
1, store
2, warehouse
3, shop

BranchItem *item_id, branch_id, qty*
1, 1, 100
1, 2, 30
2, 2, 10

I want to query for an item(coke for example) and get its quantity in all branches( even the ones it doesn't exist in, those should have NULL for qty column)
So the result should look like
1, coke, store, 100

1, coke, warehouse, 30

1, coke, shop, NULL

I have a query that can do this, but because of aliasing tables, I lose the ability to refer to the column of the result table.  The parsing of the result is done in an ORM object which preferably shouldn't be rewritten
The query I have
Select * from item left join (select * from branch left join ( select * from branchitem where item_id = 1) branchitem on branch.id = branchitem.branch_id) JOINEDNAME on true where item.id = 1;

My question is I don't want to Elias the join of branch and brunch item as I lose the ability to refer to them separately in the ORM.  How can this query be re-written so the tables retain their names? 

A:

You don't need to use subqueries:
SELECT Item.id,
       Item.name,
       Branch.name,
       BranchItem.qty
FROM Item
CROSS JOIN Branch
LEFT JOIN BranchItem ON Item.id = BranchItem.item_id
                    AND Branch.id = BranchItem.branch_id
WHERE Item.id = 1;  -- or put it into the branch join

