1、查询年龄等于 66 的员工
select * from staff where age = 66;
2、查询年龄小于 26 的员工信息
select * from staff where age < 26;
3、查询年龄小于等于 29 的员工信息
select * from staff where age <= 29;
4、查询没有身份证号的员工信息
select * from staff where idcard isnull;
5、查询有身份证号的员工信息
select * from staff where idcard isnotnull;
6、查询年龄不等于 56 的员工信息
select * from staff where age != 56;
select * from staff where age <> 56;
7、查询年龄在18岁(包含) 到 28岁(包含)之间的员工信息
select * from staff where age >= 18 && age <= 28;
select * from staff where age >= 18and age <= 28;
select * from staff where age between15and20;
8、查询性别为 男 且年龄小于 28岁的员工信息
select * from staff where gender = '男'and age < 28;
9、查询年龄等于18 或 20 或 40 的员工信息
select * from staff where age = 18or age = 20or age =40;
select * from staff where age in(18,20,40);
10、查询姓名为三个字的员工信息 _ ,这里的下划线表示占一个位,这个位置可以是任意字符
select * from emp wherenamelike'___';
11、查询身份证号最后一位是9的员工信息,这里的%表示占多个位置,这多个位置可以是任意字符。
select * from emp where idcard like'%9';
select * from emp where idcard like'_________________9';
12、查询身份证号包含45678的员工信息,百分号可以多次使用。
select * from emp where idcard like'%45678%';