Access数据库中查询数组类型字段的ASP代码SQL语法
今天在修改以前开发的一个网站的时候遇到一个问题,因为功能的需要,以前的一个数字类型字段改变为文本字段,因为这个字段需要包含多个类别的ID,以前这个字段只对应一个ID的。
网站是ASP VB语言的,数据库使用的是Access
修改数据类型之后前台的查询代码就不能使用诸如xID=1这种条件了。由于现在该字段变为文本类型,其值为数组格式,如:
1,2,3,4,5
之前的sql查询语句为:select [ID] from [table] where xID=3
相应的查询代码就应该改变为:select [ID] from [table] where ','+xID+',' like '%,3,%'
记录一下,免得以后又去翻手册那么麻烦
by crazybruce
相关文档:
SQL插入语句得到自动生成的递增 ID 值
insert into Table1(Name,des,num) values ('ltp','thisisbest',10);
select @@identity as 'Id'
随机提取条记录的例子
SQL Server:Select Top 10 * from Tablename Order ......
交叉表语句的实现:
用于:交叉表的列数是确定的
select name,sum(case subject when '数学' then source else 0 end) as '数学',
sum(case subject when '英语' then source else 0 end) as '英语',
sum(case subject when '语文' then source else 0 end) as '语文'
from test
group by name ......
一
SQL重复记录查询(转自http://blog.csdn.net/RainyLin/archive/2009/02/17/3901956.aspx)
SQL重复记录查询
1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断
select * from people
where peopleId in (select peopleId from people group ......
1 :普通SQL语句可以用Exec执行
例: Select * from tableName
Exec('select * from tableName')
& ......