查詢某一年份出生的學生 簡單查詢(sql)

2021-10-14 17:56:20 字數 1006 閱讀 7488

1.查詢學生表

查詢學生表中所有的學生資訊

select distinct 學號,姓名 from student; # 表示對學號,姓名同時滿足唯一性

select 學號 as 學生證號碼, 姓名,出生日期as 生日; # as 對查詢結果重新命名

2.練習sql執行順序。

select 子句最後執行,其他子按安書寫順序進行。

先在student表中查詢學號=001的學生,然後顯示該條件的結果。

eg:select * from student where 學號=001;

3. 算數運算子和比較運算子(+-*/, =,<>,>>=,<=)

select 教師名稱 , 教師號 from teacher where 教師名稱 is not null;

select 學號,姓名,出生日期 from student where 出生日期

select 姓名, 出生日期 from student where 出生日期 between'1991-01-01' and '1996-01-01';

select 學號,成績 from score where 成績》=70;

4.邏輯運算子

select 學號,成績 from score where 成績》=70 and 成績<=99 ;

in 是or 的簡便寫法 // not in

select 姓名,性別 from student where 姓名 in('猴子','馬雲');// or where 姓名='猴子' or 姓名='馬雲'

5.模糊查詢

猴% (2個字元,第乙個字元猴開頭)

%猴(2個字元,後面字元猴結尾)

%猴%(3個字元,中間字是猴)

select 姓名 from student where 姓名 like '%猴';

mysql 查詢某一年 某一月 某一天的資料

查詢某一年 某一月 某一天的資料 可組合 select fromymt where date format indate,y m d 2016 10 10 indate為表中列名 mysql查詢一天,查詢一周,查詢乙個月內的資料 查詢一天 select from ymt where date ind...

mysql 查詢今天 某一天 某一月 某一年的資料

今天 select from 表名 where to days 時間欄位名 to days now 昨天 包括昨天和今天的資料 select from 表名 where to days now to days 時間欄位名 1昨天 只包括昨天 select from 表名 where to days ...

Mysql中查詢某一天,某個月,某一年資料

今天 select from 表名 where to days 時間欄位名 to days now 昨天 select from 表名 where to days now to days 時間欄位名 1近7天 select from 表名 where date sub curdate interva...