Spike121 Posted April 11, 2009 Share Posted April 11, 2009 Okay, I know I already posted this in MySQL help, but there's no active users there, so I'm posting it here. I need a MySQL code that selects a random result from a table. select link from table1 Would that select a random one, or the latest entry? If it wouldn't select a random result, what would? Also, what would select the latest one too? I need both if possible. Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/153606-solved-random-mysql-result-and-latest-information-inserted/ Share on other sites More sharing options...
hastishah Posted April 11, 2009 Share Posted April 11, 2009 hi use this query for random data selection from database SELECT * FROM Tablename ORDER BY Rand( ) LIMIT 2 ; Link to comment https://forums.phpfreaks.com/topic/153606-solved-random-mysql-result-and-latest-information-inserted/#findComment-807135 Share on other sites More sharing options...
Spike121 Posted April 11, 2009 Author Share Posted April 11, 2009 What's the "LIMIT 2" for? Also, is there anything (besides "tablename") I have to edit, because I'm getting "Resource id #13" as a result. Link to comment https://forums.phpfreaks.com/topic/153606-solved-random-mysql-result-and-latest-information-inserted/#findComment-807154 Share on other sites More sharing options...
Spike121 Posted April 11, 2009 Author Share Posted April 11, 2009 Nevermind, I fixed it. Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/153606-solved-random-mysql-result-and-latest-information-inserted/#findComment-807159 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.