MYSQL条件查询

1、in 关键字:select * from 表名 where 字段 [not] in(值1,值2......);

     in()相当于一个集合

    1.1查询学生id为1,7,8的记录


   1.2查询学生id不为1,7,8的记录



2、between 关键字:select * from 表名 where 字段 [not] between 值1 and 值2;

      between 值1 and 值2表示为 :[值1,值2],是闭区间


   2.1查询学生id在3~6之间的记录


     2.2查询学生id不在3~6之间的记录



3、空值查询:select * from 表名 where 字段 is [not] null;

     3.1查询c_id字段为空值的记录

           

    3.1查询c_id字段不为空值的记录

           

猜你喜欢

转载自blog.csdn.net/study_no/article/details/79839977
今日推荐