Users Pricing

forum

Home Forums SQL selecting random rows, but not reselecting them next time – MindStick

SQL selecting random rows, but not reselecting them next time

Jayden Bell 2123 06 May 2013
Hi Everyone!

I'm making a random selection of 50 items, but when another call is made, I want to select another random 50 that DOES NOT include anything selected previously. How 

best to do this? Is there an SQL statement that handles this?

// Collect 50 random entries
$stmt = $db->query('
SELECT * FROM db
ORDER BY RAND() 
LIMIT 50    
');

Thanks in advance! 

1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md