Home >Database >Mysql Tutorial >mysql 某列指定值靠前排序

mysql 某列指定值靠前排序

WBOY
WBOYOriginal
2016-06-07 15:53:211805browse

单个列靠前排序: mysql 某列指定值靠前排序 order by case SELECT * FROM `jcxsw`.`t_company_product` order by ( case when id=263 then 1 ELSE 4 END),category_id desc; 这段sql代码 会先排列id =263的额数据 然后 根据category_id倒叙 多个列靠前排序

单个列靠前排序:

mysql 某列指定值靠前排序  order by case

SELECT * FROM `jcxsw`.`t_company_product` order by (
    case
     when id=263 then 1 ELSE 4 END),category_id desc;

这段sql代码 会先排列id =263的额数据 然后 根据category_id倒叙


多个列靠前排序:

SELECT * FROM `web_membersfastsort_women` m  order by  m.province'10106000' , m.city'10106001' ,m.city desc,m.province desc,m.s_cid asc, m.images_ischeck desc,m.pic_num desc limit 2000,30


province =10106000 的 靠前排,在province = 10106000 中   city=10106001 的靠前排

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn