I've got a table with 10 rows. I wish to get first and then any 3 random rows. Can you really do in a single query?

Thanks, aby

I'd do:

SELECT * FROM Foo ORDER BY ID LIMIT 1 --First row
UNION
SELECT * FROM Foo WHERE ID NOT IN (SELECT ID FROM Foo ORDER BY ID LIMIT 1)
   ORDER BY RAND() LIMIT 3
(SELECT * FROM table ORDER BY id ASC LIMIT 1) UNION (SELECT * FROM table ORDER BY RAND() LIMIT 3) 

Obviously, you might want to not choose the very first row within the random part, however, you stated ANY 3

I would suggest carrying this out in the application layer, as possible introduce caching later. Plus it's considerably faster to complete random procedures inside the application than reaches the database layer.

// Your database stuff

while ($row = $result->fetchRow()) {
    $results[] = $row;
}

$firstResult = array_shift($results);

for ($i = 0 ; $i < 3 ; $i++) {
    $randomKey = array_rand($results);
    $randomResults[] = $results[$randomKey];
}

echo $firstResult;

foreach ($randomResults as $randomResult) {
    echo $randomResult;
}