黑馬程序員 MySQL數(shù)據(jù)庫入門到精通,從mysql安裝到mysql高級、mys

1,找年齡為20,21,22,23的女性員工信息
select * from 表 where 性別='女' and in(20,21,22,23);
2,查詢性別為難,并且年齡在20到40歲以內(nèi)的三個字的員工
select * from 表 where 性別='男' and 年齡 between 20 and 40 and name like '___';
3,統(tǒng)計員工表中,年齡小于68歲的,男性員工與女性員工的人數(shù)
select 性別,count(*) from 表 where 年齡 < 68 group by 性別
4,查詢所有年齡小于等于35歲員工的姓名和年齡,并對查詢結(jié)果按年齡升序排列,如果年齡相同按入職時間降序排序
select 姓名,年齡 from 表 where 年齡<=35 order by 年齡 ,入職時間 desc;
5,查詢性別為男,且年齡在20-40歲以內(nèi)的前5個員工信息,對查詢的結(jié)果按年齡升序排序,年齡相同按入職時間升序排序
select * from 表 where 性別='男' and 年齡 between 20 and 40 order by 年齡 ,入職時間 limit 5 ;
標(biāo)簽: