📚 Join
1. SALESMAN의 사원번호, 이름, 급여, 부서명, 근무지코드를 조회합니다.
select e.empno, e.ename, e.sal, d.dname, d.loc_code from emp e, dept d where e.deptno=d.deptno and e.job='SALESMAN';
2.사원이름,부서명, 급여, 근무도시 명을 조회합니다.
select e.ename, d.dname, e.sal, l.city from emp e, dept d, locations l where e.deptno=d.deptno and l.loc_code=d.loc_code;
3.DALLAS에근무하는사원중 급여 1500 이상인 사원의 이름,급여,업무, 입사일, 보너스를 조회합니다.
select e.ename, e.sal, d.dname, e.hiredate, e.comm, l.city from emp e, dept d, locations l where e.deptno=d.deptno and d.loc_code=l.loc_code and sal>=1500 and l.city='DALLAS';
4. EMP 테이블과 DEPT 테이블에 있는 모든자료를 다음과 같이 조회합니다. 사원번호, 이름, 업무, EMP 테이블의부서번호, DEPT 테이블의부서번호, 부서명을 조회합니다.
select e.empno, e.ename, e.deptno, d.job, d.deptno, d.dname from emp e, dept d where e.deptno=d.deptno;
📌 여기서 모든 자료는 테이블의 모든 레코드(=행)를 의미하는 것
별표 기호(﹡)와 헷갈리지 말자! 별표 기호(﹡)는 select절에서 모든 컬럼(=열)을 조회할 수 있는 기호이다.
5.DEPT 테이블, LOCATIONS 테이블을 이용하여 부서번호, 부서명, 해당부서의city 정보를 조회합니다.
select d.deptno, d.dname, l.city from dept d, locations l where d.loc_code=l.loc_code;