select random data with a nested query?
I have a database table with quite large data. Now i want to get random 4 out of it. What i need is a query that fetches 1000 records from it and then selects random 4 out of these 1000 and gives it as a result. I think it can be done by nested query but have no开发者_开发技巧 idea how to do it. Please help me with some example code.
select * from
(
select * from your_table
where some_conditions
limit 1000
)
as some_aliases
order by rand()
limit 4;
精彩评论