简单查询
列出emp表当中的全部字段。
select * from emp;
仅列出emp表当中的ename字段。
select ename from emp;
去重查询
查询emp表当中的deptno列,要求是不要显示重复的行。
select DISTINCT deptno form emp;
条件查询
单条件查询:
查询emp表当中当中dept=1的列select * from emp where deptno=1;
查询emp表里面工资大于100的用户;select * from emp where sal>100;
多条件查询:
查询工资大于等于200且deptno=2的用户;
select * from emp where sal>=200 and deptno=2
排序查询:
单条件查询:查询emp当中所有的内容,让其按照工资升序/降序排序;
select * from emp order by sal;
select * from emp order by sal DESC;
截取练习
只显示前两行: select * from emp limit 2;
只显示第二行到第四行:select * from emp limit 1,3;