首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

where id in (.)的自动排序有关问题

2012-01-30 
where id in (...)的自动排序问题SelectProContent_nameFromProContentwhereProContent_IDin(9336,1137,84

where id in (...)的自动排序问题
Select   ProContent_name   From   ProContent   where   ProContent_ID   in   (9336,1137,8440)

这样搜索出来的数据   默认是按1137   8440   9336   来排序
如何是上面的语句按照输入的顺序来排   如:上面的语句的排序是9336,1137,8440
来排

我现在用的方法是截掉   按union   all   来链接,有其他方法吗?

[解决办法]
不使用In,而改用Exists,或把条件拆成表然后使用关联查询。
[解决办法]
Select ProContent_name From ProContent where ProContent_ID in =9336
union all
Select ProContent_name From ProContent where ProContent_ID in 1137
union all
Select ProContent_name From ProContent where ProContent_ID in =8440
[解决办法]
WNASP的方法比in 要高效。

要排序,自己选择要排序的字段,再添加一个order by 子句就可以了

热点排行