Can I do a join three times

I have four tables
a mdps table whose foreign key is the utilities tables primary key,
a upss table whose foreign key is the primary key on the mdps table
a switchers table whose foreign key is the primary key on the upss table
Im trying to get some info from each by using

SELECT AS switcher_name,switchers.manufacturer,switchers.model,switchers.frequency,switchers.capacity,switchers.voltage,switchers.notes,switchers.created_by, switchers.created_date,switchers.updated_by,switchers.updated_date,switchers.enabled, AS ups_name, upss.ups_id, AS mdp_name, mdps.mdp_id, AS utility_name, mdps.utility_id 
FROM switchers 
INNER JOIN upss ON switchers.switcher_id = upss.ups_id, 
INNER JOIN mdp ON upss.mdp_id = mdps.mdp_id, 
INNER JOIN utilities ON mdps.utility_id = utilities.utility_id 
WHERE switcher_id = 1

I thought this would be ok since all tables are connected, but

Oh, I had the table name as mdp, it should be mdps

you’ve also got commas between your inner joins, which shouldnt be there, and what MySQL is complaining about.
(Whenever MySQL tells you your problem is “near ‘X Y Z’”, look at X, and look at the thing that comes immediately before X.)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.