Ⅰ sql查询同一字段的多个值
dim type1,type2,whereStr
type1=request.form("type1")
type2=request.form("type2")
whereStr=" where 1=1"
if type1<>"" then whereStr=whereStr&" and type1='"&type1&"'"
if type2<>"" then whereStr=whereStr&" and type2="'&type2&"'"
sql="select * from [表]"&whereStr
这个sql就是你所要的查询语句,注意不要去掉各个引号中的空格
Ⅱ sql一个关键字多个字段查询
可以通过全文索引来实现
当然你的方法也可以,每个字段用上去空函数如isnull(field1,'')+isnull(field2,'')
Ⅲ sql怎么查询,A字段对应多个B字段,查询A字段,同时满足B字段对应的特定值
select 店名 from 数据库 where 产品='黄瓜'
select 店名 from 数据库 where 产品<>'黄瓜'
select 店名 from 数据库 where 产品='黄瓜' and产品='苹果'
Ⅳ sql多张表查询多个不同字段
selectt1.id1,t1.id2,t1.id3,t2.id5,t2.id6,t3.id8,t3.id9fromt1leftjoint2ont1.id1=t2.id1leftjoint3ont3.id1=t1.id1
Ⅳ SQL语句中怎样同时查询一个表中的两个字段
select 字段1,字段2,...字段n from 表名(如果有条件的话)where age=12 and name=“小名”(如果想排序的话) order by desc(asc)(如果想限制查询条数的话)limit=10
希望对你有帮助!
Ⅵ sql按多字段值条件查询问题
如果menuid是列表1,5,8
那么select distinct companyid from menutable where menuid in('1','5','8')(如果menuid为字符类型,数字类型将引号去掉)
如果传入的menuid是个字符串1,5,8
那么写成select distinct companyid from menutable where ',1,5,8,' like '%,'+cast(menuid as varchar)+',%'
Ⅶ sql 查询怎么统计多个字段各自的个数
--所有算的地方都用cast(个数asint)
createtabletest05
(avarchar(10),
bvarchar(10),
cvarchar(10))
insertintotest05select'#','一','三'unionall
select'@','一','三'unionall
select'¥','一','二'unionall
select'%','二','二'
select*fromtest05
selectb,COUNT(b)个数fromtest05groupbyb
selectc,COUNT(c)个数fromtest05groupbyc
selectSUM(isnull(t1.个数,0)+isnull(t2.个数,0))总数,sum(isnull(t1.个数,0))个数,t1.b,sum(isnull(t2.个数,0))个数,t2.cfrom
(selectb,COUNT(b)个数fromtest05groupbyb)ast1fulljoin
(selectc,COUNT(c)个数fromtest05groupbyc)ast2ont1.b=t2.c
groupbyt1.b,t2.c