Sql語句你知道多少(六)------select語句

比較、邏輯、重複查詢

查詢大於指定條件的數據

select * from tb_Student where Score>60;

NOT與謂詞進行組合的查詢

1.NOT BETWEEN

指定值的包含範圍,用and分割開始值和結束值

語法:test_expression [ NOT ] BETWEEN begin_expression AND end_expression

test_expression :這是在 begin_expressionend_expression 定義範圍中所要測試的運算是。begin_expressionend_expressiontest_expression 必須是相同的數據類型。

NOT:執行否定運算的謂詞

AND:用於指定範圍

eg:select *from tb_Student where Score [not] between 60 and 80;

2.IS[ NOT ]NULL

指定對空值和非空值的查詢

eg:

3.[NOT] IN

語法:test_expression [ NOT ] IN(subquery,expression[,...n])

test_expression:Sql表達式

subquery:包含結果集的子查詢

expression[,...n]):測試表達式

查詢時不顯示重複的記錄

DISTINCT:

select distinct english from tb_Student;//不顯示英語成績相同的記錄

顯示重複記錄的個數

select count(Score) as 學生人數,id ,name from tb_Student group by Score,id,name having count(Score)>1;

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章