1樓:匿名使用者
可以通過where條件語句實現。
sql:select * from tablename where name like '張%' and id>5;
解釋:以上就是通過條件查詢出名字以張開始的,id大於5的表資料。
備註:多條件之間如果是同時滿足用and,如果是滿足其中乙個用 or。
2樓:悉枋菲
呼叫處直接用<%=getchannelaticle(頻道id)%>簡單吧,呵呵,給分吧,不行我全程解決你!
通用遍歷頻道過程
function getchannelaticle(topn,頻道id)
getchannelaticle=""
表 where channelid=頻道id order by id desc"
set temprs=conn.execute(sql)while not temprs.eof
標題")&"
"temprs.movenext
wend
set temprs=nothing
end functiion
3樓:匿名使用者
頻道pd
文章wz
select pd,wz from 表 where pd=某頻道 order by 日期字段 desc
sql怎麼用查詢結果作為條件進行查詢 10
4樓:浪小客
1、查詢資料庫表的所有欄位並直接使用select語句。從資料庫表中選擇*。
2、查詢資料庫表的part部分字段,可以使用select field命令,從資料庫表中選擇欄位名稱。
3、根據條件查詢,使用後面的條件,加上從資料庫表中選擇條件名稱。
4、使用distinct命令查詢資料庫字段記錄中的非重複結果,從資料庫中選擇不同的欄位名稱。
5、查詢資料庫表前面的資料,可以使用top命令,從資料庫表中選擇頂部編號*。
5樓:匿名使用者
巢狀select語句也叫子查詢,乙個 select 語句的查詢結果能夠作為另乙個語句的輸入值。子查詢不但能夠出現在where子句中,也能夠出現在from子句中,作為乙個臨時表使用,也能夠出現在select list中,作為乙個欄位值來返回。
1、單行子查詢 :單行子查詢是指子查詢的返回結果只有一行資料。當主查詢語句的條件語句中引用子查詢結果時可用單行比較符號(=, >, <, >=, <=, <>)來進行比較。
例:select ename,deptno,sal from emp
where deptno=(select deptno from dept where loc='new york');
2、多行子查詢:多行子查詢即是子查詢的返回結果是多行資料。當主查詢語句的條件語句中引用子查詢結果時必須用多行比較符號(in,all,any)來進行比較。
其中,in的含義是匹配子查詢結果中的任乙個值即可("in" 操作符,能夠測試某個值是否在乙個列表中),all則必須要符合子查詢的所有值才可,any要符合子查詢結果的任何乙個值即可。而且須注意all 和any 操作符不能單獨使用,而只能與單行比較符(=、>、< 、>= 、<= 、<>)結合使用。 例:
1).多行子查詢使用in操作符號例子:
查詢選修了老師名叫rona(假設唯一)的學生名字
sql> select stname from student
where stid in(selectdistinct stid from score where teid=(select teid from teacher where tename='rona'));
查詢所有部門編號為a的資料: select ename,job,sal from emp
where deptno in ( select deptno from dept where dname like 'a%');
2).多行子查詢使用all操作符號例子:查詢有一門以上的成績高於kaka的最高成績的學生的名字: sql> select stname from student
where stid in(select distinct stid from score where score >all(select score from score where stid=(select stid from student where stname= 'kaka') )); 3). 多行子查詢使用any操作符號例子:查詢有一門以上的成績高於kaka的任何一門成績的學生的名字:
sql> select stname from student
where stid in(select distinct stid from score where score >any(select score from score where stid=(select stid from student where stname='kaka')));
希望能幫到你
6樓:時針樓
像你這種情況用 in或not in 關鍵字比較好
7樓:射手小小王
select * from table_b where people_name in (select people_name from table_a);
sql 中如何查詢乙個字段符合兩個條件
8樓:海天盛
sql中如何查詢乙個字段符合兩個條件的方法。
如下參考:
1.在計算機中,開啟foxtable軟體,新建乙個**,如學生評價結果,並輸入資料,如下圖所示。
2.然後,滑鼠左鍵單擊單鍵攻擊選單下選擇[雜項],如下圖所示。
3.然後,在選單列中,左鍵單擊[sqlquery],如下圖所示。
4.接下來,在[sqlquery]視窗中選擇資料來源,如下圖所示。
5.然後,在[sqlquery]視窗中,輸入sql查詢語句,如下圖所示。
6.接下來,在表的預覽中,您可以看到通過查詢語句顯示的資料,如下圖所示。
9樓:你以為你以為
select * from user where name='張三' and name ='李四'
select * from user where name in ('張三','李四');
分析:增加關係表,人員借書資訊表。
在book表中增加借書標記字段。
條件合適後,查詢很方便了。歡迎追問,謝謝採納!
10樓:匿名使用者
select t1.bno from
(select bno from book where 書名='書1') as t1,
(select bno from book where 書名<>'書2') as t2
where t1.bno=t2.bno
11樓:
select 借書人 from bookwhere 書名=書1
and not exist
(select * from book where 書名=借書2)
12樓:宇宙外的三道題
可用where...and語句。
如student表資料:
classid name age1 張三 191 李四 201 王五 202 趙六 182 孫七 212 楊八 19如果要查classid為1且age為20的人的資訊,可用如下語句:
select * from student where classid=1 and age=20
結果就是:
classid name age1 李四 201 王五 20select * from student where classid=1 and age=20
13樓:
select bno from book where 條件 = 書1 and 條件 <> 書2
14樓:
select * from table where book1=1 and book2=0
sql資料庫查詢中,空值查詢條件怎麼寫?
15樓:小小小小吃貨丫
1、首先需要建立資料庫表t_user_info,利用建立表sql語句create table。
2、向數版據庫表裡插
入資料,權按照插入sql語句insert into 執行。
3、插入完畢後,查詢資料庫表記錄select 字段 from table。
4、查詢資料庫表t_user_info使用者位址為空的記錄select * from table from 字段 is null。
5、查詢資料庫表t_user_info使用者**不為空的記錄,select * from table where 字段 is not null。
6、查詢資料庫表t_user_info**不為空且位址為空的記錄,select * from table where 字段 is not null and 字段 is null。
16樓:哎呀
在ms sql server和baioracle這兩個主要的資料du庫中,空值都比較特殊,不
zhi能直接用"="或dao"<>"號來比較,如果你內要用這兩個符號比較,就容
會發現,空值即不在等於的集內,也不在不等於的集內。
特別注意的是,空值用「<>」(不等於)比較時,也不在集合內!具體的你自已測試一下就明白了。
常見的做法是用"is null"或「is not null」來確定是不是空值。比如你的情況應該改寫語句為:
where itemno is null
17樓:可靠的王者
一般需要傳輸,審核,對比,通過,才肯提交,就可能查詢了
18樓:匿名使用者
什麼資料庫?
sqlserver有isnull()函式,可以直接寫成
where isnull(itemno,'')=''
19樓:匿名使用者
select * from table where itemno='' *這個就
是表示此bai字du段沒有任何zhi
值select * from table where itemno is null *這個就是表示此字段值為null
你查詢語句dao是不是還有其它的條
回件,若有,找找其答它條件是不是下錯了。
sql如何查詢空值的欄位,sql資料庫查詢中,空值查詢條件怎麼寫?
sql查詢空值的欄位寫法 select a.欄位 from student a where a.欄位 like student為表名 查詢類似空值的寫法 1 查詢名稱有退格鍵 select from t bd item info where charindex char 8 item name 0 ...
如何對mySQL資料庫中某些特定字段進行排序
set count 0 update tb t1,select count count 1 as count 日期 金額 from tb order by 日期 desc t2 set t1.日期 t2.日期 t1.金額 t2.金額 where t1.id t2.count 如何對mysql資料庫中...
資料庫用sql語句查詢是有資料的,然後前台就是查不到
1 看你前台查詢的sql語句是否正確 2 如果1正確的話,sql的查詢結果的儲存物件,看看這個物件有沒有資料 3 如果2正確的話,看你前台頁面有沒有接收到這個物件,訪問的物件屬性是否正確 我的問題是,沒有請求到對應的servlet,因為查詢的方法寫在查詢全部的那個servlet裡了,頁面跳轉選擇的粗...