select t_cp.id, t_cp.proc, t_odid_cpid.num
from t_odid_cpid
left join t_cp on t_cp.id = t_odid_cpid.cpid
left join T_ORDER on t_odid_cpid.odid = T_ORDER.odid
Where T_ORDER.B_zzdm = '785390650'。
select t_cp.id, t_cp.proc, t_odid_cpid.num
from t_odid_cpid
left join t_cp on t_cp.id = t_odid_cpid.cpid
left join T_ORDER on t_odid_cpid.odid = T_ORDER.odid
Where T_ORDER.B_zzdm = '早春785390650'
SQL语句尽量不要用子查询,子查询腊穗速度最慢的陆局耐.
select t_cp.id,t_cp.proc,t_odid_cpid.num
from t_odid_cpid
left join t_odid_cpid
on t_cp.id=t_odid_cpid.cpid
left join T_ORDER
on t_odid_cpid.odid=T_ORDER.odid
WHERE T_ORDER.B_zzdm = '785390650'携宴
写语句的时候尽量不要用蠢隐昌in,效率比较低,可以用exist或者join来替代,从而提高性能.
另外注意条带扒件及连表字段加上索引,也可以提高性能.