开发者

fetch records in specific order but keep some specific records in always top mysql

I have one DB table called table1 have some col开发者_运维技巧umns two of them are

purchased enum ('Y','N') default 'N';
created timestamp ;

I want to fetch records newest on top but the records with purchased 'Y' will always be on very top and these records should also be sorted in newest to oldest.

How do I do query?


SELECT * FROM table1 ORDER BY purchased DESC, created DESC
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜