0

table 1 : -

name | location | Area | Region | Country
-----------------------------------------
abc    8          6      9        12

table 2 : -

lid | lname | aid | rid | cid
def    8       6     9    12

table 3 : -

aid | aname | rid | cid
6      ghi     9     12

table 4 : -

rid | rname | cid
9      jkl     12

table 5 : -

cid | cname
12     mno

how can i join these 5 tables in mysql and retrive " abc, def, ghi, jkl, mno ";

fthiella
  • 48,073
  • 15
  • 90
  • 106
Mohit
  • 1,204
  • 2
  • 13
  • 19

1 Answers1

0

I hope This will work for you.

SELECT table1.name, table2.lname ,table3.aname,table4.rname,table5.cname 
FROM table1 
WHERE 
LEFT JOIN table2 ON table2.lid = table1.location
LEFT JOIN table3 ON table3.aid = table1.area
LEFT JOIN table4 ON table4.rid = table1.region
LEFT JOIN table5 ON table5.cid = table1.country
Nisarg
  • 3,024
  • 5
  • 32
  • 54