Mysql specifies the sorting Implementation Method for a row or column, and mysql specifies the sorting
Method:
Desc:
Cannot achieve:
Method 1:
Select sp. productid, sp. productname, ss. sku from sp_product sp inner join sku_skus ss on sp. productid = ss. productid where sp. productname = 'lux skin whitening soap 115g' or sp. productname = 'crest (Crest) 180 grams of Green Tea mint toothpaste 'or sp. productname = 'flavor orchard orchid bean 190g/bag 1 bag of roasted bean casual snacks 'order by (case when sp. productid = 11042723 then 1 ELSE 2 END)
Method 2:
Core SQL
Select sp. productid, sp. productname, ss. sku from sp_product sp inner join sku_skus ss on sp. productid = ss. productid where sp. productname = 'lux skin whitening soap 115g' or sp. productname = 'crest (Crest) 180 grams of Green Tea mint toothpaste 'or sp. productname = 'flavor orchard orchid bean 190g/bag 1 bag of fried bean casual snacks 'order by sp. productid not in (11042723)
Mysql: puts the specified data row at the beginning
If it is just a data row, you can do this:
SELECT * FROM user ORDER BY user_id<>7,score DESC;
This is mainly "user_id <> 7", and the user ID 7 is placed in the front.
For multiple data rows:
SELECT * FROM user ORDER BY user_id NOT IN(7,8,9),score DESC;
The specified values in a mysql column are sorted in front of each other.
Top sorting of a single column:
Order by case
SELECT * FROM `jcxsw`.`t_company_product` order by (case when id=263 then 1 ELSE 4 END),category_id desc;
The SQL code first sorts the amount of data with id = 263 and then returns the result based on the category_id.
Sort multiple columns in front:
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
The front row of province = 10106000, and the front row of city = 10106000 in province = 10106001