mysql - Order results in which it was read in. Using in() -
this query in mysql:
select school_id, first_name, last_name, email, blog_username, comment_username table user_id in (100, 3,72) ;
the results show 2 user_id's in ascending order. how can make ordered in received?
so instead of 3, 72, 100
want results 100, 3, 72
.
select school_id, first_name, last_name, email, blog_username, comment_username table user_id in ( 100, 3, 72 ) order case when user_id = 100 1 when user_id = 3 2 when user_id = 72 3 end asc
addition explanation:
what being sought ability order rows in custom manner. said way, need add custom cardinality set of values not conform standard cardinality. case expression can used that. way accomplish same thing be:
select school_id, first_name, last_name, email, blog_username, comment_username table join ( select 100 user_id, 1 sort union select 3, 2 union select 72, 3 ) seq on seq.user_id = table.user_id order seq.sort
Comments
Post a Comment