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

ASP.NET Core

 Certainly! Here are 10 advanced .NET Core interview questions covering various topics: 1. **ASP.NET Core Middleware Pipeline**: Explain the...