下面的查询在本地 phpmyadmin 上运行完美,但在服务器 phpmyadmin 上不起作用
select t.fk_user_id,
t.target_month,
t.target,
e.ce_recruiter_id,
e.billing_amount
from target t
left join closure_employee e
on t.fk_user_id = e.ce_recruiter_id
and month(t.target_month) = month(e.offer_date)
and e.offer_date > DATE_SUB(now(), INTERVAL 7 MONTH)
where t.target_month > DATE_SUB(now(), INTERVAL 7 MONTH) and t.fk_user_id ='31'
本地结果:
fk_user_id target_month target ce_recruiter_id billing_amount
31 2013-07-01 100000 NULL NULL
31 2013-08-01 100000 31 390000
31 2013-09-01 100000 31 208354
31 2013-10-01 120000 NULL NULL
31 2013-11-01 120000 NULL NULL
31 2013-12-01 120000 NULL NULL
服务器结果:
fk_user_id target_month target ce_recruiter_id billing_amount
31 2013-07-01 100000 NULL NULL
31 2013-08-01 100000 NULL NULL
31 2013-09-01 100000 NULL NULL
31 2013-10-01 120000 NULL NULL
31 2013-11-01 120000 NULL NULL
31 2013-12-01 120000 NULL NULL
我如何在服务器上获取本地结果。 请帮忙解决这个问题。
最佳答案
我们无法为您的问题提供准确的解决方案,因为我们对您的数据和/或服务器配置了解不多...但对您来说最简单的解决方案应该是检查您使用的每个条件分别检查你的“where”语句并找出哪个失败了。
select e.* from target t
left join closure_employee e on t.fk_user_id = e.ce_recruiter_id
where t.fk_user_id ='31'
select e.* from target t
left join closure_employee e on t.fk_user_id = e.ce_recruiter_id and month(t.target_month) = month(e.offer_date)
where t.fk_user_id ='31'
select e.* from target t
left join closure_employee e on t.fk_user_id = e.ce_recruiter_id and month(t.target_month) = month(e.offer_date) and e.offer_date > DATE_SUB(now(), INTERVAL 7 MONTH)
where t.fk_user_id ='31'
等等... 也许这会告诉你问题出在哪里
关于mysql - 相同的查询结果与本地的值相同,但在服务器上它显示空结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20947499/