㈠ sql如何進行多個條件查詢
select * from tab_name where 組號='001組' and to_char(日期,'yyyy-mm-dd')='2013-04-15' and 姓名1='小王' union all select * from tab_name where 組號='001組' and to_char(日期,'yyyy-mm-dd')='2013-04-15' and 姓名2='小王' union all select * from tab_name where 組號='001組' and to_char(日期,'yyyy-mm-dd')='2013-04-15' and 姓名3='小王' union all select * from tab_name where 組號='001組' and to_char(日期,'yyyy-mm-dd')='2013-04-15' and 姓名4='小王' 或者是: select * from tab_name where 組號='001組' and to_char(日期,'yyyy-mm-dd')='2013-04-15' and 姓名1='小王' or 姓名2='小王' or 姓名3='小王' or 姓名4='小王'
㈡ SQL語句where多條件查詢怎麼寫
工具/材料:以Management Studio為例。
1、首先在桌面上,點擊「Management Studio」圖標。
㈢ SQL 如何根據條件查詢不同結果
if(a=1){
Select * FROM TempTable where a=1
}
if(a=2){
Select a,b,c FROM TempTabel where a=2
}
if(a=3){
Select a,b,c,d FROM TempTabel where a=3
}
㈣ sql從同一表裡查詢多條不同條件的數據
試試:
select
a_id,
a_title,
a_name
from
A
where
a_id=10
union
all
select
*
from
(
select
top
1
a_id,
a_title,
a_name
from
A
where
a_id<10
order
by
a_id
desc)
union
all
select
top
1
a_id,
a_title,
a_name
from
A
where
a_id>10
㈤ SQL 如何不同列 顯示不同條件查詢的結果
select a.name,money1,money2 from
(
select name,sum(money) as money1
from table
where idate>1
) a
innser join (select name,sum(money) as money2
from table
where idate<1
) b on a.name=b,name
㈥ sql語句怎麼查詢三個不同條件
在where子句里設置3個篩選條件就可以了。例如:
select * from students where
sname like 'Wang%' and sex='female'
and nationality='China';
㈦ SQL分組且根據不同的條件查詢。
SELECT 名稱, 數量+(SELECT SUM(數量) FROM B表 WHERE A表.ID=B表.ID AND A表.時間<B表.時間)
FROM A表
㈧ sql中可以用select根據2個不同條件查詢同一個表同一個欄位2次嗎
使用兩個left join 就行了
select m.*,a.user_name as name1,b.user_name as name2 from message as m left join user as a on m.send_id=a.user_id left join user as b on m.get_id=b.user_id
㈨ sql不同條件查詢
select count(batch_num),sum(batch_num) from table where user_id <> 0
group by
batch_num
㈩ 怎樣在SQL資料庫中實現多條件查詢
`
主要就是在where後後使用and邏輯運算符
如:
select * from [表名] where 學校='清華大學' and 住址='北京' and 性別='男'
以上為查詢,清華大學,住址為北京的所有男性的信息
還可以使用用模糊查詢.
如:
select * from [表名] where 學校 like '%清華大學%' and 住址 like '%北京%' and 性別='男'
以上為查詢學校有清華兩字,住址中有北京兩字的所有男性的信息
要是回答的內容有問題,或認為不妥,請發送網路消息給我,消息內容加上本頁網址哦。。
·