seran128 Posted November 15, 2006 Share Posted November 15, 2006 I have a table with the following itemtbl_mytableIDTitleDescriptionI want to write a sql statment that returns the value of the id but randomlysay if the values for ID are 1,2,3,4.....I need the sql to return 2 one time then 4 the next and 1 the next and so on. Link to comment https://forums.phpfreaks.com/topic/27346-selecting-random-values/ Share on other sites More sharing options...
seran128 Posted November 15, 2006 Author Share Posted November 15, 2006 Figured it out[code]SELECT * FROM `table name` WHERE ID>= (SELECT FLOOR( MAX(ID) * RAND()) FROM `table name` ) ORDER BY ID LIMIT 1;[/code] Link to comment https://forums.phpfreaks.com/topic/27346-selecting-random-values/#findComment-125024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.