Jump to content

mysql select qustion


dzhax

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...