日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

MySQL筆記之基本查詢的應用詳解_MySQL教程

編輯Tag賺U幣

推薦:mysql密碼過期導致連接不上mysql
mysql密碼過期了,今天遇到了連接mysql,總是連接不上去,下面有兩種錯誤現(xiàn)象,有類似問題的朋友可以參考看看,或許對你有所幫助

參考表:student



多字段查詢

復制代碼 代碼如下:www.hl5o.cn

mysql> select id,name,birth from student;


所有字段查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student;


where指定查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student where id=901;
mysql> select * from student where id>=904;
mysql> select name from student where department='計算機系';


in指定集合查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student where birth in(1988,1990);
mysql> select * from student where id in(903,906);

not in非范圍查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student where birth not in(1990,1998);


between and指定范圍查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student where birth between 1986 and 1988;


not between and不在指定范圍的查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student where id not between 904 and 906;


like字符串匹配查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student where name like '_三';
mysql> select * from student where name like '張三';
mysql> select * from student where name like '張%';


not like不匹配查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student where name not like '張%';


null查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student where address is null;


and多條件查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student where name like '張%' and birth>1985;
mysql> select * from student where name like '張%' and birth>1985 and id like '%3';


or多條件查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student where id=905 or birth=1988;
mysql> select * from student where id=905 or birth=1988 or sex='女';

 

distinct查詢結(jié)果不重復

復制代碼 代碼如下:www.hl5o.cn

mysql> select distinct sex from student;
mysql> select distinct department from student;


order by查詢結(jié)果排序
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student order by birth;
mysql> select * from student order by birth asc;
mysql> select * from student order by birth desc;


group by分組查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select sex,group_concat(name) from student group by sex;
mysql> select sex,count(name) from student group by sex;


正則表達式查詢
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student where birth regexp '1988|1990';


limit限制查詢結(jié)果數(shù)量
復制代碼 代碼如下:www.hl5o.cn

mysql> select * from student limit 2;
mysql> select * from student limit 1,3;

 


分享:MySQL筆記之索引的使用
索引是創(chuàng)建在表上的,對數(shù)據(jù)庫表中一列或多列的值進行排序的一種結(jié)構(gòu)其作用主要在于提高查詢的速度,降低數(shù)據(jù)庫系統(tǒng)的性能開銷

來源:模板無憂//所屬分類:MySQL教程/更新時間:2013-05-04
相關(guān)MySQL教程