Saturday, 24 August 2013

order by 2 columns with sqlite

order by 2 columns with sqlite

I'd like to order by names however the creator should be listed first so I
wrote the below and got the error
1st ORDER BY term does not match any column in the result set
How do I write this so the creator is the first result? I don't understand
why I have this error. My query is
select u.id as id, u.name as name, 0 as creator from User u
join Moderator m on m.forumID=@forumID and m.userID=u.id
union
select u.id, u.name, f.creator as creator from User u
join Forum f on f.id=@forumID and u.id=w.creator
order by creator<>0, u.name

No comments:

Post a Comment