dzhax Posted August 26, 2010 Share Posted August 26, 2010 working on an ajax chat and i am stumped dont know if it is because ive been up too long and cant think or this actually may be a tough query.what i need:mysql select statement to print the newest 10 records according to timestamp sorting from newest to oldestI posted this in php because i figured it could not be done with one sql statement that i could just add mysql_select($sql,$con) and it would work. figured it would probly be like a 3 step process.table: chat id intbody stringtimestamp timestamp This is what i have put so far then i drew a blank: $sql = "SELECT * FRON `chat`"$records = mysql_num_rows($sql,$con);$sql = "SELECT * FROM `chat` WHERE `id` Link to comment Share on other sites More sharing options...
thescientist Posted August 26, 2010 Share Posted August 26, 2010 wouldn't it be something like: $records = mysql_query("SELECT * FROM chat ORDER BY timestamp DESC LIMIT 0,2"); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.