MySql IF条件给出意外结果

时间:2013-06-10 05:55:36

标签: mysql phpmyadmin mysql-workbench

我有以下查询,我为了简单而缩短

SELECT 
  @WD:=WORKDAYS(
        if(completionDate='0000-00-00 00:00:00',
           CURDATE(),
           completionDate
        ),d.recievingdate
  ) AS workingDays,
  @QDays:=IFNULL(QDays,0) as Q,
  @RDDays:=IFNULL(RDDays,0) As R,
  @onhold:=IFNULL(ONHOLD,0) as OnHold,
  @TDAY:=IF((@WD-@RDDays-@QDays)<=0,1,ROUND(@WD-@RDDays-@QDays)) as TDay,
  @TDAY,
  @SLA:=slatime(
         d.department,
         p.activitytype,
         slaitemId,
         @sladays:=  (SC1+SC2+SC3+SC4+SC5+SC6+SC7+SC8+SC9)
  ) as slaTime,@SLA,
  IF(@TDAY<=@SLA,'OK','NOK') AS SLACOMPLIANCE

以下是结果

PhpMyadmin结果 enter image description here

Mysql Workbench结果 enter image description here

工作台结果与预期相同,因为TDay小于SlA

相同的查询给出了不同的结果,现在我已经忘记了PHP也给出了与phpmyadmin相同的结果

我做错了什么? 注意:WORKDAYSslatime是两个自定义函数

0 个答案:

没有答案