{"id":6417,"date":"2017-04-18T08:56:12","date_gmt":"2017-04-18T08:56:12","guid":{"rendered":"http:\/\/www.withdata.com\/blog\/?p=6417"},"modified":"2017-04-20T11:20:03","modified_gmt":"2017-04-20T11:20:03","slug":"how-to-select-n-random-records-from-a-sqlite-table","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/tips\/how-to-select-n-random-records-from-a-sqlite-table.html","title":{"rendered":"How to select N random records from a SQLite table"},"content":{"rendered":"<p>If you want to select N random records from a SQLite table, you need to change the clause as follows:<\/p>\n<p><strong>select * from tableName order by RANDOM() limit N<\/strong><\/p>\n<p>For example, to select 5 random customers in the customers table, you use the following query:<\/p>\n<p><strong>select * from customers order by RANDOM() limit 5<\/strong><\/p>\n<p>Some SQLite tools you can try: <a href=\"https:\/\/www.withdata.com\/sqlite\/\"> https:\/\/www.withdata.com\/sqlite\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to select N random records from a SQLite table, you need to change the clause as follows: select * from tableName order by RANDOM() limit N For example, to select 5 random customers in the customers table, you use the following query: select * from customers order by RANDOM() limit 5 Some [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[1964,1369],"class_list":["post-6417","post","type-post","status-publish","format-standard","hentry","category-tips","tag-random-records","tag-sqlite"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/6417","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/comments?post=6417"}],"version-history":[{"count":2,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/6417\/revisions"}],"predecessor-version":[{"id":6484,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/6417\/revisions\/6484"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=6417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=6417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=6417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}