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. 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 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. Link to comment https://forums.phpfreaks.com/topic/215854-order-by-subquery/#findComment-1122114 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.