目次
多字段查询
所有字段查询
where指定查询
in指定集合查询
not in非范围查询
between and指定范围查询
not between and不在指定范围的查询
like字符串匹配查询
not like不匹配查询
空值查询
and多条件查询
or多条件查询
distinct查询结果不重复
order by查询结果排序
group by分组查询
limit限制查询结果数量
ホームページ データベース mysql チュートリアル MySQL学习笔记7:基本查询_MySQL

MySQL学习笔记7:基本查询_MySQL

Jun 01, 2016 pm 01:37 PM
mysql

bitsCN.com

参考表:student


 

多字段查询
mysql> select id,name,birth from student;
ログイン後にコピー

 

所有字段查询
mysql> select * from student;
ログイン後にコピー

 

where指定查询
mysql> select * from student where id=901;mysql> select * from student where id>=904;mysql> select name from student where department='计算机系';
ログイン後にコピー

 

in指定集合查询
mysql> select * from student where birth in(1988,1990);mysql> select * from student where id in(903,906);
ログイン後にコピー

 

not in非范围查询
mysql> select * from student where birth not in(1990,1998);
ログイン後にコピー

 

between and指定范围查询
mysql> select * from student where birth between 1986 and 1988;
ログイン後にコピー

 

not between and不在指定范围的查询
mysql> select * from student where id not between 904 and 906;
ログイン後にコピー

 

like字符串匹配查询
mysql> select * from student where name like '_三';mysql> select * from student where name like '张三';mysql> select * from student where name like '张%';
ログイン後にコピー

 

not like不匹配查询
mysql> select * from student where name not like '张%';
ログイン後にコピー

 

空值查询
mysql> select * from student where address is null;
ログイン後にコピー

 

and多条件查询
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多条件查询
mysql> select * from student where id=905 or birth=1988;mysql> select * from student where id=905 or birth=1988 or sex='女';
ログイン後にコピー

 

distinct查询结果不重复
mysql> select distinct sex from student;mysql> select distinct department from student;
ログイン後にコピー

 

order by查询结果排序
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分组查询
mysql> select sex,group_concat(name) from student group by sex;mysql> select sex,count(name) from student group by sex;
ログイン後にコピー

 

limit限制查询结果数量
mysql> select * from student limit 2;mysql> select * from student limit 1,3;
ログイン後にコピー

 

 

bitsCN.com
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

PHPのビッグデータ構造処理スキル PHPのビッグデータ構造処理スキル May 08, 2024 am 10:24 AM

PHPのビッグデータ構造処理スキル

PHP で MySQL クエリのパフォーマンスを最適化するにはどうすればよいですか? PHP で MySQL クエリのパフォーマンスを最適化するにはどうすればよいですか? Jun 03, 2024 pm 08:11 PM

PHP で MySQL クエリのパフォーマンスを最適化するにはどうすればよいですか?

PHP で MySQL のバックアップと復元を使用するにはどうすればよいですか? PHP で MySQL のバックアップと復元を使用するにはどうすればよいですか? Jun 03, 2024 pm 12:19 PM

PHP で MySQL のバックアップと復元を使用するにはどうすればよいですか?

PHP を使用して MySQL テーブルにデータを挿入するにはどうすればよいですか? PHP を使用して MySQL テーブルにデータを挿入するにはどうすればよいですか? Jun 02, 2024 pm 02:26 PM

PHP を使用して MySQL テーブルにデータを挿入するにはどうすればよいですか?

データベースにおける Java 列挙型のアプリケーション シナリオは何ですか? データベースにおける Java 列挙型のアプリケーション シナリオは何ですか? May 05, 2024 am 09:06 AM

データベースにおける Java 列挙型のアプリケーション シナリオは何ですか?

MySQL 8.4 で mysql_native_password がロードされていないエラーを修正する方法 MySQL 8.4 で mysql_native_password がロードされていないエラーを修正する方法 Dec 09, 2024 am 11:42 AM

MySQL 8.4 で mysql_native_password がロードされていないエラーを修正する方法

PHP で MySQL ストアド プロシージャを使用するにはどうすればよいですか? PHP で MySQL ストアド プロシージャを使用するにはどうすればよいですか? Jun 02, 2024 pm 02:13 PM

PHP で MySQL ストアド プロシージャを使用するにはどうすればよいですか?

PHP を使用して MySQL テーブルを作成するにはどうすればよいですか? PHP を使用して MySQL テーブルを作成するにはどうすればよいですか? Jun 04, 2024 pm 01:57 PM

PHP を使用して MySQL テーブルを作成するにはどうすればよいですか?

See all articles