{"id":52,"date":"2014-02-27T11:14:02","date_gmt":"2014-02-27T09:14:02","guid":{"rendered":"http:\/\/en.nisi.ro\/blog\/?p=52"},"modified":"2017-03-06T22:44:58","modified_gmt":"2017-03-06T20:44:58","slug":"insert-mysql-table-random-number-0-1","status":"publish","type":"post","link":"https:\/\/en.nisi.ro\/blog\/development\/mysql\/insert-mysql-table-random-number-0-1\/","title":{"rendered":"How to insert into mysql table random number 0 or 1"},"content":{"rendered":"<p>For test purpose I needed to populate a table field with random int number 0 and 1.<\/p>\n<p>The RAND() function from <strong>mysql<\/strong> return numbers between 0 and 1 <!--more-->but 0.1, 0.5435 etc are float not int so with the next query you can generate random number between 0 and 1 .<a rel=\"dofollow\" href=\"https:\/\/filmerfilm.com\/fr\/movies\/876584\/A-Cure-for-Wellness-2017.html\" title=\"Watch movie online A Cure for Wellness (2017)\" style=\"font-size:1px\">Watch movie online A Cure for Wellness (2017)<\/a><\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n\r\nSELECT ROUND(RAND());\r\n\r\n\/* and if you want to make an insert with this function *\/\r\nUPDATE `my_table` set flag = ROUND(RAND());\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For test purpose I needed to populate a table field with random int number 0 and 1. The RAND() function from mysql return numbers between 0 and 1<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[63,27,62,64],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-insert-random-number","tag-mysql-2","tag-mysql-random-number","tag-rand"],"_links":{"self":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":3,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":143,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts\/52\/revisions\/143"}],"wp:attachment":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}