这是我的SQL查询:
select name,description
from wp_widget_custom
where name in ('hemel-hempstead','maidenhead',
'guildford','bromley','east-london','hertfordshire','billericay','surrey')
Run Code Online (Sandbox Code Playgroud)
我得到的结果是这种形式:
name description
hemel-hempstead Loreum ipsim
east-london Loreum ipsim
bromley Loreum ipsim BROMLEY
billericay Loreum ipsim
maidenhead Loreum ipsim maidenhead
hertfordshire Loreum ipsim HERTFORDSHIRE
guildford loreum ipsum Guildford
surrey loreum ipsum surrey
Run Code Online (Sandbox Code Playgroud)
我希望结果按照在查询中传递的方式排列:
hemel-hempstead ,maidenhead',guildford,bromley,east-london......
Run Code Online (Sandbox Code Playgroud)
非常感谢帮助,谢谢.
按字段排序:
select name, description
from wp_widget_custom
where name in ('hemel-hempstead','maidenhead','guildford','bromley','east-london','hertfordshire','billericay','surrey')
order by field(name, 'hemel-hempstead','maidenhead','guildford','bromley','east-london','hertfordshire','billericay','surrey')
Run Code Online (Sandbox Code Playgroud)