MySQL 테이블에는 다른 테이블의 ID에 해당하는 여러 키가 있습니다.
두 테이블 간의 대응:
$user_address=D('UserAddress')->query("SELECT m.id,name,phone,address,m.province,n.areaname,m .city,o.areaname as Area2name, m.district,p.areaname as Area3name FROM `ez_user_address` as m INNER JOIN ez_area as n on m.province=n.id INNER JOIN ez_area as o on m.city=o.id 내부 조인 ez_area를 p로 m.district=p.id WHERE m.id=1");<code class="prettyprint linenums lang-php">$user_address=D('UserAddress')->query("SELECT m.id,name,phone,address,m.province,n.areaname,m.city,o.areaname as area2name, m.district,p.areaname as area3name FROM `ez_user_address` as m INNER JOIN ez_area as n on m.province=n.id INNER JOIN ez_area as o on m.city=o.id INNER JOIN ez_area as p on m.district=p.id WHERE m.id=1");<br>
// dump($user_address);exit;
// dump($user_address);exit;결과 인쇄: