記事のディレクトリ
サポートされる演算子
- 比較演算子
- 論理演算子
- ファジィクエリ
- 範囲クエリ
- 空の判決
どこクエリ条件をフォーマット
select * from 表名 where 条件;
例:
select * from students where id = 1;
比較演算子
- イコール=
- >より大きい
- より大きい又は> =等しいです
- 未満<
- 未満または<=等しいです
- 等しくない!=または<>
例1:查询编号大于3的学生:
select * from students where id > 3;
例2:查询编号不大于4的学生:
select * from students where id <= 4;
例3:查询姓名不是“黄蓉”的学生:
select * from students where name != '黄蓉';
例4:查询没被删除的学生:
select * from students where is_delete=0;
論理演算子クエリ
- そして
- 若しくは
- ではありません
例1:女子学生のクエリ数が3以上です。
select * from students where id > 3 and gender=0;
例2:2かいない学生が削除され未満問い合わせ番号:
select * from students where id < 2 or is_delete=0;
例3:クエリは、23と24歳の生徒の年齢ではありません。
select * from students where not (age >= 23and age <= 24);
説明:
所望の全体として複数の条件を決定し、「()」に組み込まれてもよいです。
ファジィクエリ
- キーワードファジークエリのような
- %は任意の数の文字を表します
- _任意の文字を表します
例1:クエリの学生は、黄の某:
select * from students where name like '黄%';
例2:クエリは、黄の某と「名前」は、学生の言葉です。
select * from students where name like '黄_';
例3:クエリまたは呼び出しがどのような学生黄チーの某:
select * from students where name like '黄%' or name like '%琦';
範囲クエリ
- 間...そして...連続した範囲内でクエリを表現します
- 中には、非連続的な範囲でのクエリことを示しています
例1:学生3-8の問合せ数:
select * from students where id between 3 and 8;
若しくは
select * from students where id>=3 and id<=8;
例2:クエリの数が8に男の子3ではありません。
select * from students where (not id between 3 and 8) and gender='男';
若しくは
select * from students where not (id>=3 and id<=8);
空の判決
- 空白を使用して決定されるnullです
- null以外の使用を分析すると、nullでありません
例1:クエリは、生徒の高さを記入していません。
select * from students where height is null;
注意:
図1は、使用できない高さ=ヌルヌルここで決定される
高さ!= NULLが空決定場合2使用できない
3ヌルが空の文字列「に等しくありません