Mysql 语句/多个时按情况排序

Mysql 语句/多个时按情况排序,mysql,sql,sql-order-by,Mysql,Sql,Sql Order By,我想在我的请求中添加一个条款: SELECT * FROM MV_immo WHERE bien != 'Autre' AND bien != 'Indifférent' ORDER BY case when vendue = 'AV' then 1 when vendue = 'VPNA' then 2 when vendue = 'EC' then 3 else 6 end, Id DESC LIMIT 0,6 现在,我有一个列“position”(int),我

我想在我的请求中添加一个条款:

SELECT * FROM MV_immo 
WHERE bien != 'Autre' AND bien != 'Indifférent' 
ORDER BY case
    when vendue = 'AV' then 1
    when vendue = 'VPNA' then 2
    when vendue = 'EC' then 3
else 6 end, Id DESC LIMIT 0,6
现在,我有一个列“position”(int),我想保留第一个order并添加order“position”子句(类似这样的内容:

或者……

SELECT * FROM MV_immo 
WHERE bien != 'Autre' AND bien != 'Indifférent' 
ORDER BY case
when vendue = 'AV', position ASC then 1
when vendue = 'VPNA', position ASC then 2
when vendue = 'EC', position ASC then 3
else 6 end, Id DESC LIMIT 0,6

我的目标是保留第一个订单(由卖方订购),并添加第二个订单条款:位置
我需要您的帮助,因为我正在启动php,这对我来说并不简单。
我如何才能做到这一点?

如果我理解正确,您希望:

ORDER BY (case when vendue = 'AV' then 1
               when vendue = 'VPNA' then 2
               when vendue = 'EC' then 3
               else 6
          end),
         position,
         Id DESC
如果愿意,您可以缩短此长度:

order by field(vendue, 'EC', 'VPNA', 'AV') desc, position, id

请注意,
字段()调用中的值顺序相反。

如果我理解正确,您需要:

ORDER BY (case when vendue = 'AV' then 1
               when vendue = 'VPNA' then 2
               when vendue = 'EC' then 3
               else 6
          end),
         position,
         Id DESC
如果愿意,您可以缩短此长度:

order by field(vendue, 'EC', 'VPNA', 'AV') desc, position, id

请注意,
字段()中的值顺序相反。
调用。

为什么在大小写表达式中?我想你只需要在Id之前加上“position”:否则6 end,position ASC,Id DESC LIMIT 0,6为什么在case表达式中?我想你只需要把“位置”放在Id之前:否则6结束,位置ASC,Id描述限制0,6