Easiest way to choose a percentage of an amount of rows from a MySQL table?

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2010-05-05T06:30:34Z Indexed on 2010/05/05 6:58 UTC
Read the original article Hit count: 175

Filed under:
|
|

I have a script that has a GET variable: $_GET['percentage']

I have a MySQL table of data.

Now lets say that there are 100 rows of data in this table.

In pseudo-code:

SELECT data FROM table

Now would it be possible to select $_GET['percentage'] of random data from table?

For example (again in pseudo-code):

$_GET['percentage'] = 10;
SELECT 10% of data from table order by rand()

If this IS possible, how could I do it?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql