Home  >  Article  >  Backend Development  >  sql关联有关问题ABC三个表

sql关联有关问题ABC三个表

WBOY
WBOYOriginal
2016-06-13 12:09:43930browse

sql关联问题A\B\C三个表,
sql关联问题A\B\C三个表,A.id = B.aid   和A.id= C.a2id,这种关联如何写?
------解决思路----------------------

<br />select A.*,B.*,C.* from A<br />left join B on A.id = B.aid<br />left join C on A.id = B. a2id<br />

------解决思路----------------------
$user = M('A');
$user->join("left join B on A.id=B.Id left join C on c.id=b.id")->field("A.id as aid,B,id as bid,……")->select(); 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn