表1: -
name | location | Area | Region | Country
-----------------------------------------
abc 8 6 9 12
表2: -
lid | lname | aid | rid | cid
def 8 6 9 12
表3: -
aid | aname | rid | cid
6 ghi 9 12
表4: -
rid | rname | cid
9 jkl 12
表5: -
cid | cname
12 mno
如何在mysql中加入这5个表并检索“abc,def,ghi,jkl,mno”;
答案 0 :(得分:0)
我希望这对你有用。
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