i have made a table for an audit trail.
CREATE TABLE IF NOT EXISTS `audit_trail_timer` (
`_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`remaining_duration` varchar(50) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`_id`)
)
now i wanted to select a row where the timestamp is the most recent one.
$query = select * from audit_trail_timer where user_id='$id' and timestamp='';
try this
SELECT * FROM audit_trail_timer WHERE user_id='$id'
ORDER BY TIMESTAMP DESC LIMIT 1
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments