当前位置:首页 > 技术杂谈 > 正文

数据库之十:谓词

2024-03-31 技术杂谈

1、比较谓词:

=、<、>、<>


2、like:
模糊查询 _代表一个字符,%代表0个或者多个字符:

select * from student where sid like _1%

表示sid的第二个字符是1的所有数据


3、between:

select * from student where sage between 19 and 21

范围查询,包含端点的值


4、is nullis not null:
用来判断空值情况的

select * from student where ssex is not null

 

5、in:

select * from student where sid in(select sid from student where ssex=)

查询所有性别为男性的信息(语句不需要这么写,只是为了说明in谓词),同样的有not in


6、exists:
判断是否存在满足某种条件的记录,exist谓词的主语是记录;
EXIST只关心记录是否存在,返回哪些列都没有关系
对应的是not exist

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/a/22966.html