mysql - 相同的查询结果与本地的值相同,但在服务器上它显示空结果

标签 mysql

下面的查询在本地 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/

相关文章:

mysql - 如何连接三个不同的表,其中一列是每个组件的总和?

mysql 1054,未知列,但我没有指定列

php - 在 PHP 中使用 mysqldump 而不使用整个路径

javascript - 使用 jquery 忽略链接、复选框……在可编辑的 html 字段中

mysql - 执行 'LOAD DATA LOCAL INFILE 时发生异常

mysql - 在 MySQL 中存储复杂的 perl 数据结构

mysql - 组依赖SQL设计

php - 树莓派 phpmyadmin 500 错误

mysql - GROUP BY HAVING 没有按预期工作

php - MySQL MAX 子查询