MySQL筆記之基本查詢的應用詳解_MySQL教程
推薦:mysql密碼過期導致連接不上mysqlmysql密碼過期了,今天遇到了連接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)的性能開銷
相關(guān)MySQL教程:
- MSSQL清空日志刪除日志文件
- 關(guān)于數(shù)據(jù)庫中保留小數(shù)位的問題
- 解析mysql與Oracle update的區(qū)別
- mysql 導入導出數(shù)據(jù)庫以及函數(shù)、存儲過程的介紹
- MySQL——修改root密碼的4種方法(以windows為例)
- 解決MYSQL出現(xiàn)Can''t create/write to file ''#sql_5c0_0.MYD''的問題
- 深入理解SQL的四種連接-左外連接、右外連接、內(nèi)連接、全連接
- 解析:內(nèi)聯(lián),左外聯(lián),右外聯(lián),全連接,交叉連接的區(qū)別
- mysql出現(xiàn)“Incorrect key file for table”處理方法
- mysql重裝后出現(xiàn)亂碼設置為utf8可解決
- 淺析一個MYSQL語法(在查詢中使用count)的兼容性問題
- 解析MySQL中INSERT INTO SELECT的使用
- 相關(guān)鏈接:
- 教程說明:
MySQL教程-MySQL筆記之基本查詢的應用詳解
。