Pawn Posted October 14, 2010 Share Posted October 14, 2010 Hiya. I have a statement similar to: SELECT * FROM posts WHERE post_id NOT IN('121 84 376 20 3 94 1'); I'd like the "excluded" posts to be returned at the end of the results set, rather than skipped. Pseudo code: SELECT excluded = IN('121 84 376 20 3 94 1') ? 1 : 0 ORDER BY excluded ASC Any pointers much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/215854-order-by-subquery/ Share on other sites More sharing options...
awjudd Posted October 14, 2010 Share Posted October 14, 2010 Would something like this work? SELECT ( post_id IN ( 121, 84, 376, 20, 3, 94, 1 ) ) AS excluded FROM posts ~judda Quote Link to comment https://forums.phpfreaks.com/topic/215854-order-by-subquery/#findComment-1122106 Share on other sites More sharing options...
Pawn Posted October 14, 2010 Author Share Posted October 14, 2010 Bingo! Nicely done. Quote Link to comment https://forums.phpfreaks.com/topic/215854-order-by-subquery/#findComment-1122114 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.