{"id":88,"date":"2020-07-01T17:13:18","date_gmt":"2020-07-01T17:13:18","guid":{"rendered":"https:\/\/lmponceb.com\/?p=88"},"modified":"2021-02-09T23:09:20","modified_gmt":"2021-02-09T23:09:20","slug":"variables-en-mysql","status":"publish","type":"post","link":"https:\/\/lmponceb.com\/index.php\/2020\/07\/01\/variables-en-mysql\/","title":{"rendered":"Variables en MySQL"},"content":{"rendered":"\n<p><strong>Problema:<\/strong><\/p>\n\n\n\n<p>Tengo una serie de consultas SQL que ejecuto de tanto en cuanto, y cada vez que ejecuto debo cambiar par\u00e1metros como la fecha o alg\u00fan valor X. <\/p>\n\n\n\n<p><strong>Soluci\u00f3n:<\/strong><\/p>\n\n\n\n<p>En MySQL, es posible utilizar variables al inicio del script que luego pueden ser utilizadas por las diferentes consultas<\/p>\n\n\n\n<p>Definir una variable:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-vivid-cyan-blue-color has-very-light-gray-background-color\">SET @date_var = &#8216;2020-05-30&#8217;;<\/p>\n\n\n\n<p>Consumir una variable:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-vivid-cyan-blue-color has-very-light-gray-background-color\">SELECT * FROM table<br>WHERE date(date_field) = @date_var<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problema: Tengo una serie de consultas SQL que ejecuto de tanto en cuanto, y cada vez que ejecuto debo cambiar par\u00e1metros como la fecha o alg\u00fan valor X. Soluci\u00f3n: En MySQL, es posible utilizar variables al inicio del script que luego pueden ser utilizadas por las diferentes consultas Definir una variable: SET @date_var = &#8216;2020-05-30&#8217;; &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lmponceb.com\/index.php\/2020\/07\/01\/variables-en-mysql\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Variables en MySQL&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[12],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mysql"],"_links":{"self":[{"href":"https:\/\/lmponceb.com\/index.php\/wp-json\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lmponceb.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lmponceb.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lmponceb.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lmponceb.com\/index.php\/wp-json\/wp\/v2\/comments?post=88"}],"version-history":[{"count":1,"href":"https:\/\/lmponceb.com\/index.php\/wp-json\/wp\/v2\/posts\/88\/revisions"}],"predecessor-version":[{"id":89,"href":"https:\/\/lmponceb.com\/index.php\/wp-json\/wp\/v2\/posts\/88\/revisions\/89"}],"wp:attachment":[{"href":"https:\/\/lmponceb.com\/index.php\/wp-json\/wp\/v2\/media?parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lmponceb.com\/index.php\/wp-json\/wp\/v2\/categories?post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lmponceb.com\/index.php\/wp-json\/wp\/v2\/tags?post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}