peace
peace

Reputation: 21

mysql Join table

I'm trying to join these tables:

            table1             table2             table3              
        -------------------------------------------------
             table1Id           table2Id           table3Id
               name              table1Id          table2Id
                                   name2             name3

How do I join these 3 tables?

for example something like this: PS. Example is not working

SELECT table1.name, table2.name2 , table3.name3 from table3 
left join  on(table2.table2Id=table3.table2Id)
left join  on(table1.table1Id=table2.table1Id) group by  table1.table1Id

Upvotes: 1

Views: 60

Answers (1)

Kevin Bowersox
Kevin Bowersox

Reputation: 94429

The table name must be specified after left join. Also there is no need to use group by in this scenario.

SELECT table1.name, table2.name2 , table3.name3 
from table3 
left join table2 
on table3.table2Id = table2.table2Id
left join table1 
on table2.table1Id = table1.table1Id

Upvotes: 1

Related Questions