PDA

View Full Version : 2 inner joins?


jarv
05-15-2009, 12:02 PM
Can anyone help?

I have 3 tables

stores - StoreID / StoreName
branches - BranchID / StoreID
reports - BranchID

I just want to get the StoreName?!


SELECT * FROM reports INNER JOIN branches ON branches.BranchID=reports.branchID INNER JOIN stores ON branches.StoreID=stores.StoreID

my code outputs missing operator

Can someone please help?

Fumigator
05-15-2009, 05:08 PM
Looks fine to me, so can we see the exact error you get?

Old Pedant
05-15-2009, 07:22 PM
Is it possible that reports is a keyword???

If so, try the query with `...` around that word:

SELECT *
FROM `reports`
INNER JOIN branches ON branches.BranchID=`reports`.branchID
INNER JOIN stores ON branches.StoreID=stores.StoreID

I assume we don't need to tell you about how bad it is to use SELECT * ??