-- SELECT * FROM 表明 [WHERE 条件语句];
SELECT * FROM emp;
SELECT ename,hiredate,sal,deptno FROM emp;
-- 查询不从重复的记录
SELECT DISTINCT ename FROM emp;
-- 条件查询
SELECT * FROM emp WHERE sal = 100;
SELECT * FROM emp WHERE sal = 4000 AND deptno = 1;
2.连接查询
-- 内连接
-- 查询员工的名字和部门
SELECT ename,deptname FROM emp,dept WHERE emp.deptno = dept.deptno;
-- 左外连接
SELECT ename,deptname FROM emp
LEFT JOIN dept ON emp.deptno = dept.deptno;
-- 右外连接
SELECT ename,deptname FROM dept
RIGHT JOIN emp ON emp.deptno = dept.deptno;