0

表格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”;

4

1 回答 1

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
于 2013-06-22T07:10:49.997 回答