MySQL筆記之基本查詢的應(yīng)用詳解_MySQL教程
推薦:mysql密碼過期導(dǎo)致連接不上mysqlmysql密碼過期了,今天遇到了連接mysql,總是連接不上去,下面有兩種錯(cuò)誤現(xiàn)象,有類似問題的朋友可以參考看看,或許對你有所幫助
參考表:student

多字段查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select id,name,birth from student;
所有字段查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select * from student;
where指定查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select * from student where id=901;
mysql> select * from student where id>=904;
mysql> select name from student where department='計(jì)算機(jī)系';
in指定集合查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select * from student where birth in(1988,1990);
mysql> select * from student where id in(903,906);
not in非范圍查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select * from student where birth not in(1990,1998);
between and指定范圍查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select * from student where birth between 1986 and 1988;
not between and不在指定范圍的查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select * from student where id not between 904 and 906;
like字符串匹配查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select * from student where name like '_三';
mysql> select * from student where name like '張三';
mysql> select * from student where name like '張%';
not like不匹配查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select * from student where name not like '張%';
null查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select * from student where address is null;
and多條件查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
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多條件查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select * from student where id=905 or birth=1988;
mysql> select * from student where id=905 or birth=1988 or sex='女';
distinct查詢結(jié)果不重復(fù)
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select distinct sex from student;
mysql> select distinct department from student;
order by查詢結(jié)果排序
復(fù)制代碼 代碼如下:www.ghpqjb.com
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分組查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select sex,group_concat(name) from student group by sex;
mysql> select sex,count(name) from student group by sex;
正則表達(dá)式查詢
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select * from student where birth regexp '1988|1990';
limit限制查詢結(jié)果數(shù)量
復(fù)制代碼 代碼如下:www.ghpqjb.com
mysql> select * from student limit 2;
mysql> select * from student limit 1,3;
分享:MySQL筆記之索引的使用索引是創(chuàng)建在表上的,對數(shù)據(jù)庫表中一列或多列的值進(jìn)行排序的一種結(jié)構(gòu)其作用主要在于提高查詢的速度,降低數(shù)據(jù)庫系統(tǒng)的性能開銷
相關(guān)MySQL教程:
- MSSQL清空日志刪除日志文件
- 關(guān)于數(shù)據(jù)庫中保留小數(shù)位的問題
- 解析mysql與Oracle update的區(qū)別
- mysql 導(dǎo)入導(dǎo)出數(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)亂碼設(shè)置為utf8可解決
- 淺析一個(gè)MYSQL語法(在查詢中使用count)的兼容性問題
- 解析MySQL中INSERT INTO SELECT的使用
MySQL教程Rss訂閱編程教程搜索
MySQL教程推薦
- MySQL數(shù)據(jù)庫InnoDB數(shù)據(jù)恢復(fù)工具的使用小結(jié)詳解
- 如何用cmd連接Mysql數(shù)據(jù)庫
- Mysql兩種情況下更新字段中部分?jǐn)?shù)據(jù)的方法
- MySQL筆記之?dāng)?shù)據(jù)類型詳解
- 淺談SQLite時(shí)間函數(shù)的使用說明與總結(jié)分析
- MYSQL索引無效和索引有效的詳細(xì)介紹
- MySQL:數(shù)據(jù)庫知識點(diǎn)
- mysql解決遠(yuǎn)程不能訪問的二種方法
- MySQL 生成隨機(jī)密碼
- DBA應(yīng)該知道的一些關(guān)于SQL Server跟蹤標(biāo)記的使用
猜你也喜歡看這些
- 相關(guān)鏈接:
- 教程說明:
MySQL教程-MySQL筆記之基本查詢的應(yīng)用詳解
。