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

sql查询 - MS-SQL Server / 疑难问题

table aa
(
id int ,--自动编号
userid int ,--用户id 
prcid int ,--产品id
str varchar(2000)---数字字符串
)
id userid str
1 2 '1,2,3,4,5'
2 3 ',23,4,5'
3 4 '1,2,5,4'
已经获取在str列中最小唯一值是3
如何根据3获取3所在列的id值或userid值??
结果是什么

没明白什么意思

SQL code:
select userid
from tb
where charindex(',3,',','+str+',')>0
group by userid


SQL code:
select * from tb where charindex(',3,',','+str+',')>0


SQL code:


create table aa
(
id int ,--自动编号
userid int ,--用户id
prcid int ,--产品id
str varchar(2000)---数字字符串
)
insert aa (id ,userid ,str)
select 1 ,2, '1,2,3,4,5' union all
select 2, 3, '23,4,5' union all
select 3, 4, '1,2,5,4'



with cte as(
select
a.id,userid,b.value
from
(select id,userid,str=convert(xml,'<root><row>'+replace(str,',','</row><row>')+'</row></root>') from aa)a
outer apply
(select value=T.C.value('.','nvarchar(100)') from a.str.nodes('/root/row')T(C))b)

select top 1 * from (
selec


相关问答:

SQL如何优化问题 - MS-SQL Server / 疑难问题

今天做了一个存储过程   环境是SQL2000数据库  
大致如下
建立临时表
定义员工游标
        循环员工(属于1个公司)  
        ......

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

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

vs2008 连接mysql? - MS-SQL Server / 基础类

请问
添加新数据源->数据库->添加连接
这个界面下,数据源选择:Microsoft SQL Server (SqlClient);
服务器名:
应该写什么呢?
有谁知道?多谢各位!!
你到底是要连mysql还是mssql?

引用
请问
......

请教SQLSERVER的两个问题 - MS-SQL Server / 疑难问题

1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......

Sql语句出错, - Web 开发 / ASP

运行后报错误如下:
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 '数学 + 4where 姓名='王静'' 中。
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号