美文网首页
Mysql操作——DQL-2-条件查询

Mysql操作——DQL-2-条件查询

作者: 乄Denve彡 | 来源:发表于2019-03-22 13:15 被阅读0次
条件查询

条件查询就是在查询时给出where子句,在where子句中可以使用一些运算符及关键字。

\color{red}{常用条件查询符及关键字}

=(等于)、!=(不等于)、<>(不等于)、<(小于)、<=(小于等于)、>(大于)、>=(大于等于)
between....and;值在什么范围
in(set);固定的范围值
is null;(为空)
is not null; (不为空)
and 与
or 或
not 非

使用
  1. 查询性别为男,且年龄为20的学生记录
mysql> select * from students where gender='男' and age=20;
  1. 查询学号为2,或者名为denve的学生记录
mysql> select * from students where id=2 or name='denve';
  1. 查询学号为1,2,5,的学生记录
#方法一
mysql> select * from students where id=1 or id=2 or id=5;
#方法二
mysql> select * from students where id in(1,2,5);

4.查询年龄为Null的学生记录

mysql> select * from students where name is null;

5.查询年龄不为Null的学生记录

mysql> select * from students where name is not null;

6.查询性别非男的学生记录

mysql> select * from students where gender!='男';

7.查询年龄在18到20岁之间的学生记录

#方法一
mysql> select * from students where age>=18 and age<=20;
#方法二
mysql> select * from students where age between 18 and 20;

相关文章

  • Mysql操作——DQL-2-条件查询

    条件查询 条件查询就是在查询时给出where子句,在where子句中可以使用一些运算符及关键字。 =(等于)、!=...

  • mysql,库管理与表管理1

    关于数据库的操作 (以下操作均在MySQL中进行) 表管理 单表查询 有条件的查询:

  • 2018-03-20

    MYSQL查询语句 MYSQL复杂操作语句 MYSQL多表查询方法 函数部分

  • MySQL--基础二

    本节总结MySQL的筛选条件,聚合与分组,子查询,连接查询。 MySQL的筛选条件 MySQL中的比较运算符: 比...

  • MySQL数据操作语言:条件查询

    条件查询 很多时候,用户感兴趣的并不是逻辑表里的全部记录,而只是它们当中能够满足某一种或某几种条件的记录。这类条件...

  • MySQL安全模式

    MySQL安全模式要求不能对非主键的条件查询做update和delete操作报错: update activity...

  • mysql 查询

    mysql的查询、子查询及连接查询 一、mysql查询的五种子句 where(条件查询)、having(筛选)、g...

  • MySql的查询总结

    Num01-->mysql基本查询 Num02-->mysql条件查询 Num03-->mysql聚合函数 Num...

  • mysql进阶(<( ̄︶ ̄)↗[GO!])

    对mysql数据的进一步操作查询。 mysql的条件 使用where子句对表中的数据筛选,结果为true的行会出...

  • MySql查询-条件查询

    使用where子句对表中的数据筛选,结果为true的行会出现在结果集中 语法如下: where后面支持多种运算符,...

网友评论

      本文标题:Mysql操作——DQL-2-条件查询

      本文链接:https://www.haomeiwen.com/subject/sfmlvqtx.html