查询所有列
*表示所有列
eg:查询所有的员工信息
Select * from emp;
查询指定列
Select empno,ename,deptno from emp;
常见的运算符
关系运算符:=、!=、<>、>=、、<=
区间:between A and B -》[A,B]
AND:并且,和
Or:或者
No:否,非
Is Not null:非空
In:在什么里面
或or、并且and
例:查询性别女,并且 年龄65的记录
select * from stu where gender='female' and age = "65";
例:查询学号是S_1001或者名字为Lisi的记录。
select * from stu where sid = 'S_1001' or age = "65";
例:查询学号是S_1001,S_1002,S_1003的记录
写法一:select * from stu where sid = 'S_1001' or sid = 'S_1002' or sid = 'S_1003';
在什么里面in
例:查询学号不是S_1001,S_1002,S_1003的记录
select * from stu where sid not in('S_1001','S_1002','S_1003');
是否为空is(not)null
例:查询年龄为null的记录
select * from stu where age is null;
例:查询名字不为空的学生信息
select * from stu where sname is not null;
区间between
例:查询年龄为20~40岁之间的
方式一:select * from stu where age >= 20 and age <= 40;
非not
查询性别:非男的 学生记录
select * from stu where gender !='male';