So I started my coding wit MYSQL and I have a table like following
CREATE TABLE IF NOT EXISTS `my_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) DEFAULT NULL,
`school_division` int(11) DEFAULT NULL,
`name` varchar(255) NOT NULL,
`email` text NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=32 ;
Now I want to show the recently joined students of a class in that class page. How can i do it? I tried the following.
"SELECT * FROM my_users WHERE school_division={$divsion} ORDER BY 'id' DESC LIMIT 0 , 5";
But its listing only the first five students of the class. These students are the first joined users. How can I get the last 5 students who joined?
Use
dateinstead ofid: