易截截图软件、单文件、免安装、纯绿色、仅160KB

寻求一sql查询 - MS-SQL Server / 基础类

有几千行数据.
查询时候
select * from ssq where 编号 in('1','2','2','4')
如何使编号为2的出现两次

如果

select * from ssq where 编号 in('1','2','2','4','4','4')
使2出现2次,4 出现3次

编号 in 后面可以跟几百个编号的情况,谁有好的解决办法,谢谢了!!
你的数据时什么样的?

select * from ssq where 编号 =1
union all
select * from ssq where 编号 =2
union all
select * from ssq where 编号 =3
union al 
select * from ssq where 编号 =4
 
数据表结构复杂和数据量特别大的时候建议用查询计划仔细份分析 比选一下各种方案


in里出现的重复是不起作用的

SQL code:
----------------------------------------------------------------------------------
-- Author : htl258(Tony)
-- Date : 2010-05-15 08:58:38
-- Version: Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)
-- Jul 9 2008 14:43:34
-- Copyright (c) 1988-2008 Microsoft Corporation
-- Developer Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 2)
-- Blog : http://blog.csdn.net/htl258
----------------------------------------------------------------------------------

--> 生成测试数据表: [TB]
IF OBJECT_ID('[TB]') IS NOT NULL
DROP TABLE [TB]
GO
CREATE TABLE [TB] ([Id] [int],[PId] [int])
INSERT INTO [TB]
SELECT '1','0' UNION ALL
SE


相关问答:

csv文件转换成sql导入到数据库,没有数据为何?

执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

Asp+sql server问题 - Web 开发 / ASP

我一个项目,有个插入操作,具体是这样的:
我有进货信息表。在出货时选择相应的进货信息,输入数量,选择部门后,点保存按钮,由于网络延时,点一下没有反映,于是用户就又点一下,导致一次插入了两条记录:
例: ......

数据以xml格式返回 - MS-SQL Server / 应用实例

从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
   <folder state="unchecked&qu ......

SQL server分解XML - MS-SQL Server / 应用实例

下面是XML初始文件内容
XML code:
<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/Up ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号