开发者

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

开发者 https://www.devze.com 2023-02-10 04:49 出处:网络
I have one DB table called table1 have some col开发者_运维技巧umns two of them are purchased enum (\'Y\',\'N\') default \'N\';

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

精彩评论

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