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
上一个写错了
那怎样去A表和B表和C表里的值呢?万一有一样的,name字段
select A.*,B.*,C.* from Aleft join B on A.id = B.aidleft join C on A.id = C.a2id
上一个写错了
那怎样去A表和B表和C表里的值呢?万一有一样的,name字段
你可以指定别名啊 例如
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
上一个写错了
那怎样去A表和B表和C表里的值呢?万一有一样的,name字段
你可以指定别名啊 例如
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
上一个写错了
那怎样去A表和B表和C表里的值呢?万一有一样的,name字段
你可以指定别名啊 例如
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
用thinkphp的关联形式$user->join("A on B.aid=A.id")这种形式,怎么写这种关联?
这个建议你看一下: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();