當前位置:首頁 » 編程語言 » sql怎麼查多個欄位值
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

sql怎麼查多個欄位值

發布時間: 2022-07-22 18:48:37

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欄位對應的特定值

  1. select 店名 from 資料庫 where 產品='黃瓜'

  2. select 店名 from 資料庫 where 產品<>'黃瓜'

  3. 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