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

一个sql相减的问题 - MS-SQL Server / 疑难问题

一个字段是这样的 x 可以放多个值.. 传进来是字符串, ==> 12,13,14...20 如 select * from tableName where x in(12,13,14...20) 原始数据是这样..但是我想要得到 select * from tableName where x in(1,2,3...9) 

也就是在原来的基础上减去11 ---?>>select * from tableName where x in(1,2,3...9)
没看明白 ,帮顶。


贴出表结构,数据
以及你要的结果

参考以下
SQL code:

create table #t(
id varchar(10))
declare @str varchar(300)
set @str='12,13,14,20'
declare @i int
declare @len int

set @i = 1
while @i < len(@str+',')
begin
insert #t select substring(@str+',',@i,charindex(',',@str+',',@i)-@i)
set @i = charindex(',',@str+',',@i)+1
end
select * from #t
/*
id
----------
12
13
14
20

(所影响的行数为 4 行)
*/
--drop table #t


create table a
(
id int identity(1,1) not null,
x int not null ----- 这个字段是保存1。..9 的数据 但是程序传过来的数据是 12,13,14...20 一个字符串
)


insert into a select 1 union all select 2 union all select 3 ,,,union all select 9

SQL code:


id varchar(10))
declare @str varchar(300)
set @str='12,13,14,20'
declare


相关问答:

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

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

一条 SQL - Oracle / 基础和管理

有这样一条SQL
 Select Get_Costtaxrate(col1), Get_Tcostvalue(col1) from a
 
其中Get_Costtaxrate、Get_Tcostvalue都是函数,这两个函数里面都是查找一个大表,Get_Tcostvalue还需要调用Get_C ......

关于SQL语句OR的问题 - Oracle / 高级技术

通过NAME字段条件查询一个数据表,假设我有100个姓名,有以下两个方法,
方法1:
把100个Name 组成一个SQL语句,比如 Select * from tmp_table where Name='张三' or Name ='李四' Or ...Or Name='第一百个姓名'
......

sql语句问题 - Java / Web 开发

select o_customer,o_price from orders having o_price >=avg(o_price)
select o_customer,o_price from orders where o_price >=(select avg(o_price) from orders)
我感觉没有区别啊,怎么在mysql会有 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号