rkstevens Posted April 1, 2008 Share Posted April 1, 2008 I have a timestamp table in my database, which gets a new record added at certain modification times. the timestamp is the only field in the table, and is the primary key. I have tried the query: "SELECT * FROM Updated ORDER BY 'Update' DESC LIMIT 1" which would (in my mind) return the highest (or most current) timestamp. Unfortunately, it does not, and just returns the first record in the table. Adding or removing the 'DESC' does not change this; neither does removing the 'LIMIT 1'. Not sure what I am doing wrong. Link to comment https://forums.phpfreaks.com/topic/99080-solved-timestamp-table-in-database/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 1, 2008 Share Posted April 1, 2008 Remove the single-quotes from around 'Update'. Single-quotes make it a string, not a column name. Link to comment https://forums.phpfreaks.com/topic/99080-solved-timestamp-table-in-database/#findComment-506966 Share on other sites More sharing options...
rkstevens Posted April 2, 2008 Author Share Posted April 2, 2008 $update_query = "SELECT * FROM Updated ORDER BY Update DESC LIMIT 1"; $update_data = mysql_query($update_query) or die("Error in accessing database: Update"); without the single quotes around 'Update' I get an SQL error Link to comment https://forums.phpfreaks.com/topic/99080-solved-timestamp-table-in-database/#findComment-507008 Share on other sites More sharing options...
teng84 Posted April 2, 2008 Share Posted April 2, 2008 update is reserve words so you should use back ticks on it select * from `update` Link to comment https://forums.phpfreaks.com/topic/99080-solved-timestamp-table-in-database/#findComment-507012 Share on other sites More sharing options...
rkstevens Posted April 2, 2008 Author Share Posted April 2, 2008 That works! Thank you. Link to comment https://forums.phpfreaks.com/topic/99080-solved-timestamp-table-in-database/#findComment-507018 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.