Reputation: 49
i want run mysql query to do:
first get threads order by 'olaviat' desc
then get thread order by time_update desc
i type this code:
select *
from groups_thread
where group_id = $groupid
order by olaviat,time_update desc
limit $limit,36"
but this code run order by time_update desc and show olaviat in last of anythings
olaviat is number - time_update is number too
so anyone can help me with this?
Upvotes: 1
Views: 42
Reputation: 172378
Try like this:
select *
from groups_thread
where group_id = $groupid
order by olaviat desc,time_update desc
limit $limit,36
You need to specify the sorting order for olaviat
as be default it takes it as ASCENDING
Upvotes: 1
Reputation: 21657
If you don't write anything in a order by, it defaults to ASC
(ascending order). You have to specify order by olaviat desc
to sort it in descending order:
select *
from groups_thread
where group_id = $groupid
order by olaviat desc,time_update desc
limit $limit,36
Upvotes: 2