Last post Apr 27, 2016 08:25 AM by Ramesses
Apr 26, 2016 07:44 AM|prasadr07|LINK
I have a table with this structure,
By default (admin role) topicid should show always in the top .
Note : There will be only one admin.
Admin Userid : 10
wherever i am executing the query,i need to get admin topic should be On the top
This was i am trying to get result
Apr 26, 2016 09:10 AM|raju dasa|LINK
Try this query:
select * from Topic where userid=10
select * from Topic where userid<>10
Apr 26, 2016 01:25 PM|limno|LINK
Order by Case when UserId=10 then 0 else 1 End
Apr 27, 2016 12:59 AM|Das.Sandeep|LINK
You can write in single query like below.
Select UserID, TopicID, Case When TopicId=0 then 0 else 1 End as OrderShow
From Topic Order by OrderShow
Apr 27, 2016 08:25 AM|Ramesses|LINK
use case statements like
Select UserID, TopicID, OrderShow
From Topic Order by case when OrderShow =10 then 1 else OrderShow end
this will show Ordershow value 10 at top.
Hope this helps