SELECT u.uid, u.uname, p.aname AS province_name, c.aname AS city_name, a.aname AS area_name
FROM tbl_user AS u
LEFT JOIN tbl_area AS p ON p.id = u.province_id
LEFT JOIN tbl_area AS c ON c.id = u.city_id
LEFT JOIN tbl_area AS a ON a.id = u.area_id
LIMIT 100
你确定上面的信息只通过2张表就能查询到?
province_name,city_name,area_name这3字段都没出现!
答案如@黄弘 所说。
但更好的设计应该是区分三张表,因为省、市、县基本就是常量表,基本不会发生改变,用不同的表存储会比较好。