{"id":2798,"date":"2020-05-13T12:37:22","date_gmt":"2020-05-13T11:37:22","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=2798"},"modified":"2023-06-20T15:46:07","modified_gmt":"2023-06-20T14:46:07","slug":"numeric-values","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/mysql\/queries\/update-queries\/numeric-values","title":{"rendered":"Numeric values"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Increment<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>UPDATE  table\r\nSET     field = field + 1\r\nWHERE   id = $number<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Decrement but don&#8217;t go below a value<\/h4>\n\n\n\n<p>GREATEST allows you to specify that the greater of multiple values should  used.  So in this example if the value drops below zero, zero will be greater used:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UPDATE  table\nSET     field = GREATEST(0, field - 1)\nWHERE   id = $number<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Increment but don&#8217;t go above a value<\/h4>\n\n\n\n<p>LEAST allows you to specify that the lower of multiple values should used. So in this example if the value goes above below 9999, 9999 will be used:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UPDATE  table\nSET     field = LEAST(9999, field - 1)\nWHERE   id = $number<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Increment Decrement but don&#8217;t go below a value GREATEST allows you to specify that the greater of multiple values should used. So in this example if the value drops below zero, zero will be greater used: Increment but don&#8217;t go above a value LEAST allows you to specify that the lower of multiple values should [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[240],"tags":[],"class_list":["post-2798","post","type-post","status-publish","format-standard","hentry","category-update-queries"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2798","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=2798"}],"version-history":[{"count":5,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2798\/revisions"}],"predecessor-version":[{"id":4518,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2798\/revisions\/4518"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=2798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=2798"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=2798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}