善用mysql中join的on条件内可以带and建立多条件join

mysql join on 可以带and,例如:
SELECT pa.name as name, pa.sn as sn, re.created, sl.sn, re.phase, rd.times, ABS(sl.quantity) as quantity, dr.name as dname, dr.specifications as specifications
FROM rr AS re JOIN red AS rd ON re.id = rd.rid JOIN drug AS dr ON dr.id = rd.did JOIN {{bbbb}} AS sl ON re.id = sl.r_id AND sl.d_id = rd.d_id JOIN pp AS pa ON pa.id = re.p_id
WHERE $where AND sl.receive_id >0
用于将被join表没有对应数据的时候也可以将主join表的数据显示出来

QQ截图20160530000552