我有如下因素MySQL查询,并试图右外连接,但无法understan如何做到这一点外部联接在MySQL Qyery
这里查询plase任何一个帮助
select lp_des.lpname,today.cnt_veh_tdy,todate.cnt_veh_tdate
from
(select distinct registration.lpcode,loadingpoint.lpname
from registration,loadingpoint
where registration.lpcode=loadingpoint.lpcode) lp_des,
(select lpcode,count(vehicleno) cnt_veh_tdate
from registration
where registration.companycode='01'
group by lpcode) todate,
(
select lpcode,count(vehicleno) cnt_veh_tdy
from registration
where registration.companycode='01'
and registration.date=(select max(date) from registration)
group by lpcode) today
right outer join today on lp_des.lpcode = today.lpcode
right outer join todate on lp_des.lpcode = todate.lpcode
我想做出正确的外连接的这部分
where lp_des.lpcode=todate.lpcode
and lp_des.lpcode=today.lpcode
请提前感谢
它是否必须是“正确的外部连接”?也许你应该描述你想要的结果,而不是只发布你认为需要的解决方案。 – GolezTrol 2012-03-31 06:49:40
此外,关于整个世界使用'左join'(='左外join')。每一个正确的加入对A和B可以改写为左连接B和A,这使得它更具可读性。特别是在一个查询中混合正确的连接和左连接使得读取,测试和修改变得更加困难。 – GolezTrol 2012-03-31 06:51:56
我做了右外连接在上面的查询请立即赤什么可能是语法错误在查询 – 2012-03-31 06:51:57