sql查询以显示特定项目 [英] sql query to display particular item on to
本文介绍了sql查询以显示特定项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从数据库绑定contry dropdownlis,我想显示印度作为第一项剩余国家名称我需要使用sql查询以升序显示
解决方案
选择Country_Name来自CountryTable,其中Country_Name ='India'
union all
从CountryTable中选择Country_Name,其中Country_Name<>'India'
为了以特定的顺序请求SQL表单项,您需要有一个可以对其进行排序的列:例如,一个DisplayOrder列。
Country DisplayOrder
美国2
法国3
印度1然后您可以使用SQL查询来决定将它们显示在哪个订单中:
SELECT 国家 FROM MyTable ORDER BY DisplayOrder ASC
I am binding contry dropdownlis from database,i want to display india as a first item remaining country name I need display in ascending order using sql query
解决方案
Select Country_Name From CountryTable where Country_Name='India'
union all
Select Country_Name from CountryTable where Country_Name<>'India'
In order to request items form SQL in a specif order, you need to have a column on which it can sort: a DisplayOrder column for example.
Country DisplayOrder USA 2 France 3 India 1You can then use an SQL query to decide which order to display them in:
SELECT Country FROM MyTable ORDER BY DisplayOrder ASC
这篇关于sql查询以显示特定项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文