Thursday, March 7, 2013

Get random rows from a table in mysql

if you want to get random rows from your table  so you can use rand() function of my sql in order by clause. 

so for using this you have to use this in order by clause. 

SELECT id,title,publishDate FROM mytable ORDER BY RAND()  LIMIT 5

but how its works ? how rand() function generates rows randomly . 

actually rand() function generates  a random floating-point value v in the range 0 <= v < 1.0. If a constant integer argument N is specified, it is used as the seed value, which produces a repeatable sequence of column values


No comments:

Post a Comment

can you please explain me Backpropagation & Gradients in layman language as simple as possible

 Absolutely! Let’s break down backpropagation and gradients in the simplest possible way , like we’re teaching a curious 10-year-old. 🎯...