Rumah >pembangunan bahagian belakang >tutorial php >sql关联问题ABC三个表,
sql关联问题A\B\C三个表,A.id = B.aid 和A.id= C.a2id,这种关联如何写?
select A.*,B.*,C.* from Aleft join B on A.id = B.aidleft join C on A.id = B. a2id
select A.*,B.*,C.* from Aleft join B on A.id = B.aidleft join C on A.id = C.a2id
select A.*,B.*,C.* from Aleft join B on A.id = B.aidleft join C on A.id = C.a2id
select A.*,B.*,C.* from Aleft join B on A.id = B.aidleft join C on A.id = C.a2id
select A.name as aname,B.name as bname,C.name as cname from Aleft join B on A.id = B.aidleft join C on A.id = C.a2id
select A.*,B.*,C.* from Aleft join B on A.id = B.aidleft join C on A.id = C.a2id
select A.name as aname,B.name as bname,C.name as cname from Aleft join B on A.id = B.aidleft join C on A.id = C.a2id
select A.*,B.*,C.* from Aleft join B on A.id = B.aidleft join C on A.id = C.a2id
select A.name as aname,B.name as bname,C.name as cname from Aleft join B on A.id = B.aidleft join C on A.id = C.a2id
这个建议你看一下:http://doc.thinkphp.cn/manual/continuous_operation.html
这个建议你看一下:http://doc.thinkphp.cn/manual/continuous_operation.html
$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();