Reputation: 163
$sqlsl = "select * from newmessage where sendto='".$userid."' order by inboxid limit 10";
Pease help me,
Above table retrieve first 10 rows in my badabase in ASC order. My database contain 100 recordes. I want only first 10 recordes in DESCing order
Upvotes: 1
Views: 15418
Reputation: 3634
Use this
select * from (select * from newmessage where sendto='".$userid."' order by inboxid limit 10) as message_id order by message_id desc
Upvotes: 0
Reputation: 311
Please try
"$sqlsl = "select * from newmessage where sendto='".$userid."'
order by inboxid DESC limit 10";
See this page in the MySQL documentation.
Upvotes: 3
Reputation: 3470
$sqlsl = "select * from newmessage where sendto='".$userid."' order by inboxid DESC limit 10";
Upvotes: 5
Reputation: 454950
To get the records in descending order you should add the DESC
keyword to the order by
clause:
$sqlsl = "select * from newmessage
where sendto='".$userid."'
order by inboxid desc
limit 10";
Upvotes: 2