本文介绍了SQL QUERY结果安排问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的SQL查询:

select name,description 
from wp_widget_custom 
where name in ('hemel-hempstead','maidenhead',
  'guildford','bromley','east-london','hertfordshire','billericay','surrey')

我得到的结果是这种形式:

The result I am getting is in this form:

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

我希望结果按在查询中传递的方式进行排列:

I want the result to be arranged the way it was passed in the query:

hemel-hempstead ,maidenhead',guildford,bromley,east-london......

非常感谢您的帮助.

推荐答案

按字段排序:

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')

这篇关于SQL QUERY结果安排问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 22:55