太乱了。看不清,把上面的四个表order,agentbalance,product,agent从头开始命名为a,b,c,d
select (你所要的那些字段前缀带上表名)from a inner join b inner join c inner join b on a.pro_id=c.pro_id and b.age_id=d.age_id and left(age_id,6)=left(pro_id,6)
select a.order_id,a.order_sum,a.order_provindetime,b.bal_balanceforecase,b.bal_rebate,c.proname,d.agename from order as a inner join prodcut as c inner join agentbalance as b inner join agentas d where a.pro_id=c.pro_id and b.age_id=d.age_id and left(age_id,6)=left(pro_id,6)
晕,这么长:
try:
select a.order_id,a.order_sum,a.order_provindetime,b.bal_balanceforecase,b.bal_rebate,c.proname,d.agename from order as a inner join prodcut as c,agentbalance as b inner join agentas d where a.pro_id=c.pro_id and b.age_id=d.age_id