علاء محمد
علاء محمد

Reputation: 91

mysql order by views then order these result by id desc

i want to order by views desc then by id desc i've tried

ORDER BY `id` DESC , `views` DESC 

and

ORDER BY `views ` DESC , `id` DESC 

it did not gave me the result i need

i want to get the most recent news by views

table news
id int(11)|views int(11)

any help please

Upvotes: 0

Views: 53

Answers (3)

David Elliman
David Elliman

Reputation: 1399

I think the syntax is usually ORDER BY id, views DESC

Upvotes: 1

echo_Me
echo_Me

Reputation: 37233

then use the order views first and then id.

try this

   ORDER BY  `views` DESC ,`id` DESC 

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1270181

Then put the variables in the right order in the clause:

ORDER BY `views` DESC, `id` DESC 

Upvotes: 1

Related Questions