我试图在
PHP中运行SQL查询并按一个列排序,但按特定顺序排序
我试过这个:
$sql3="SELECT * from extension where client_id = '".$result2["id"]."' ORDER BY FIELD(type,'term','queue','ivr','voicecentre','conference','callback','intercom','queuecentre') ";
但它根本就没有订购
试试这个.希望充分利用你.
select a.col as type,coalesce (
COUNT
,0) ascount
from
(select ‘A’ as col union all
select ‘B’ as col union all
select ‘C’ as col union all
select ‘D’ as col )a
left join Table1 T
on a.col=T.type
order by FIELD(a.col,’A’,’B’,’C’,’D’) ;