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

多字段查詢(xún)
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select id,name,birth from student;
所有字段查詢(xún)
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select * from student;
where指定查詢(xún)
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select * from student where id=901;
mysql> select * from student where id>=904;
mysql> select name from student where department='計(jì)算機(jī)系';
in指定集合查詢(xún)
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select * from student where birth in(1988,1990);
mysql> select * from student where id in(903,906);
not in非范圍查詢(xún)
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select * from student where birth not in(1990,1998);
between and指定范圍查詢(xún)
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select * from student where birth between 1986 and 1988;
not between and不在指定范圍的查詢(xún)
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select * from student where id not between 904 and 906;
like字符串匹配查詢(xún)
復(fù)制代碼 代碼如下: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不匹配查詢(xún)
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select * from student where name not like '張%';
null查詢(xún)
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select * from student where address is null;
and多條件查詢(xún)
復(fù)制代碼 代碼如下: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多條件查詢(xún)
復(fù)制代碼 代碼如下: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查詢(xún)結(jié)果不重復(fù)
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select distinct sex from student;
mysql> select distinct department from student;
order by查詢(xún)結(jié)果排序
復(fù)制代碼 代碼如下: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分組查詢(xún)
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select sex,group_concat(name) from student group by sex;
mysql> select sex,count(name) from student group by sex;
正則表達(dá)式查詢(xún)
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select * from student where birth regexp '1988|1990';
limit限制查詢(xún)結(jié)果數(shù)量
復(fù)制代碼 代碼如下:hl5o.cn
mysql> select * from student limit 2;
mysql> select * from student limit 1,3;
分享:MySQL筆記之索引的使用索引是創(chuàng)建在表上的,對(duì)數(shù)據(jù)庫(kù)表中一列或多列的值進(jìn)行排序的一種結(jié)構(gòu)其作用主要在于提高查詢(xún)的速度,降低數(shù)據(jù)庫(kù)系統(tǒng)的性能開(kāi)銷(xiāo)
相關(guān)MySQL教程:
- MSSQL清空日志刪除日志文件
- 關(guān)于數(shù)據(jù)庫(kù)中保留小數(shù)位的問(wèn)題
- 解析mysql與Oracle update的區(qū)別
- mysql 導(dǎo)入導(dǎo)出數(shù)據(jù)庫(kù)以及函數(shù)、存儲(chǔ)過(guò)程的介紹
- MySQL——修改root密碼的4種方法(以windows為例)
- 解決MYSQL出現(xiàn)Can''t create/write to file ''#sql_5c0_0.MYD''的問(wèn)題
- 深入理解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語(yǔ)法(在查詢(xún)中使用count)的兼容性問(wèn)題
- 解析MySQL中INSERT INTO SELECT的使用
MySQL教程Rss訂閱編程教程搜索
MySQL教程推薦
- MySQL數(shù)據(jù)庫(kù)InnoDB數(shù)據(jù)恢復(fù)工具的使用小結(jié)詳解
- 如何用cmd連接Mysql數(shù)據(jù)庫(kù)
- Mysql兩種情況下更新字段中部分?jǐn)?shù)據(jù)的方法
- MySQL筆記之?dāng)?shù)據(jù)類(lèi)型詳解
- 淺談SQLite時(shí)間函數(shù)的使用說(shuō)明與總結(jié)分析
- MYSQL索引無(wú)效和索引有效的詳細(xì)介紹
- MySQL:數(shù)據(jù)庫(kù)知識(shí)點(diǎn)
- mysql解決遠(yuǎn)程不能訪(fǎng)問(wèn)的二種方法
- MySQL 生成隨機(jī)密碼
- DBA應(yīng)該知道的一些關(guān)于SQL Server跟蹤標(biāo)記的使用
猜你也喜歡看這些
- SQL2000 事務(wù)回滾問(wèn)題探討
- SQL Server 2005 CE軟件環(huán)境需求
- SQL語(yǔ)句查詢(xún)是否為空 =null及null
- 談數(shù)據(jù)庫(kù)手邊系列:SQL Server數(shù)據(jù)表信息
- SQLServer 2008中的代碼安全(四) 主密鑰
- 解讀SQL Server數(shù)據(jù)庫(kù)的數(shù)據(jù)類(lèi)型
- 解讀SQL Server小知識(shí):Processor Affinity
- 教你幾個(gè)MySQL鮮為人知特殊技巧
- SQL普通表轉(zhuǎn)分區(qū)表的方法
- 解讀常規(guī)數(shù)據(jù)庫(kù)維護(hù)涉及的5項(xiàng)工作
- 相關(guān)鏈接:
- 教程說(shuō)明:
MySQL教程-MySQL筆記之基本查詢(xún)的應(yīng)用詳解
。