{"id":7276,"date":"2014-06-03T23:30:23","date_gmt":"2014-06-03T23:30:23","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/06\/03\/mysql-if-condition-giving-unexpected-results-collection-of-common-programming-errors\/"},"modified":"2014-06-03T23:30:23","modified_gmt":"2014-06-03T23:30:23","slug":"mysql-if-condition-giving-unexpected-results-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/06\/03\/mysql-if-condition-giving-unexpected-results-collection-of-common-programming-errors\/","title":{"rendered":"MySql IF condition giving Unexpected Results-Collection of common programming errors"},"content":{"rendered":"<p>I have the following query which i&#8217;m cutting short for simplicity<\/p>\n<pre><code>SELECT \n  @WD:=WORKDAYS(\n        if(completionDate='0000-00-00 00:00:00',\n           CURDATE(),\n           completionDate\n        ),d.recievingdate\n  ) AS workingDays,\n  @QDays:=IFNULL(QDays,0) as Q,\n  @RDDays:=IFNULL(RDDays,0) As R,\n  @onhold:=IFNULL(ONHOLD,0) as OnHold,\n  @TDAY:=IF((@WD-@RDDays-@QDays)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I have the following query which i&#8217;m cutting short for simplicity SELECT @WD:=WORKDAYS( if(completionDate=&#8217;0000-00-00 00:00:00&#8242;, 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)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7276","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7276"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7276\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}