Hey,
In mysql can you order items by when they were last updated?
like
What would I put order by to get the last updated ones first?Code:$last_updated = mysql_query("SELECT id,name,email,status FROM user WHERE status = 'online' ORDER BY ");
Thanks
Printable View
Hey,
In mysql can you order items by when they were last updated?
like
What would I put order by to get the last updated ones first?Code:$last_updated = mysql_query("SELECT id,name,email,status FROM user WHERE status = 'online' ORDER BY ");
Thanks
I'm pretty sure that you can't. You need to have a column that states when your entry was last updated and have that field updated every time you update that particular entry.
or something like that will work.Code:$last_updated = mysql_query("SELECT id,name,email,status FROM
user WHERE status = 'online' ORDER BY date2 desc");
Correct. So change how it stores the information. For reasons like this (just that generally it is more flexible) it's very common to use a timestamp instead of any formatted date. From that you can get a formatted date or use the timestamp as-is, such as for ordering.