I feel like my question is extremely basic and has been answered before but I just can't seem to find anything about it.
Let's say I have a column named 'Names' and another called 'Level'.
-----------------------
Names | Level
-----------------------
Scooby | 3
Daphne | 1
Shaggy | 2
Fred | 3
Velma | 2
Scrappy | 0
Basically I need a random name from the 'Names' column where 'Level' = 2. In this case randomly Shaggy or Velma. In reality the database will probably be in the dozens if not hundreds of the same 'Level' value.
I've seen code using:
SELECT column FROM table
ORDER BY RAND()
LIMIT 1
And I've tried playing with WHERE in there but with no success. Any ideas? Using PHP to fetch the data from MySQL to return to a Flash file. I apologize for the simplicity of the question.
Have you tried this?
SELECT `Names` FROM `table_name`
WHERE `level` = 2
ORDER BY RAND()
LIMIT 1
SELECT Names FROM table1
where Level = 2
ORDER BY RAND()
LIMIT 1