-- EMP ํ
์ด๋ธ ์กฐํ
SELECT * FROM EMP;
-- EMP ํ
์ด๋ธ ์ค ENAME ์ปฌ๋ผ๋ง ์กฐํ
SELECT ENAME FROM EMP;
SELECT ENAME FROM EMP;
-- EMP ํ
์ด๋ธ ์ค DEPTNO๊ฐ 20์ธ ๋ฐ์ดํฐ๋ง ์กฐํ
SELECT * FROM EMP WHERE DEPTNO = 20; -- ์ปจํธ๋กค + ์ํฐ
-- EMP ํ
์ด๋ธ ์ค DEPTNO๊ฐ 20์ด ์๋ ๋ฐ์ดํฐ๋ง ์กฐํ
SELECT * FROM EMP WHERE DEPTNO != 20;
-- EMP ํ
์ด๋ธ์์ ๊ธ์ฌ ( SAL )๊ฐ 800์ด์์ด๊ณ 1200 ์ดํ์ธ ์ฌ๋ ๊ฒ์
SELECT * FROM EMP WHERE SAL >= 800 AND SAL <= 1200;
-- EMP ํ
์ด๋ธ์์ DEPTNO๊ฐ 20์ด๊ณ ๊ธ์ฌ ( SAL )๊ฐ 1200๋ฏธ๋ง์ธ ์ฌ๋ ๊ฒ์
SELECT * FROM EMP WHERE DEPTNO = 20 AND SAL < 1200;
-- EMP ํ
์ด๋ธ์์ DEPTNO๊ฐ 20์ด๊ณ ENAME์ด SMITH์ธ ์ฌ๋ ๊ฒ์
SELECT * FROM EMP WHERE DEPTNO = 20 AND ENAME = 'SMITH';
-- ์ฌ์๋ฒํธ ( EMPNO )๊ฐ 7500์ด์์ด๊ณ ๊ธ์ฌ ( SAL )๊ฐ 1200 ์ด์์ธ ์ฌ์ ์ด๋ฆ ( ENAME )๊ฒ์
SELECT ENAME FROM EMP WHERE EMPNO >= 7500 AND SAL >= 1200;
-- DEPTNO๊ฐ 20์ด๊ณ JOB์ด SALESMAN ์ด๋ MANAGER์ธ ์ฌ์ ๊ฒ์
SELECT * FROM EMP WHERE DEPTNO = 20 AND (JOB = 'SALESMAN' OR JOB = 'MANAGER');
SELECT * FROM EMP WHERE DEPTNO = 20 AND JOB = 'SALESMAN' OR JOB = 'MANAGER';
-- AND ์ฐ์ฐ์๊ฐ OR๋ณด๋ค ๋จผ์ ์คํ๋๋ค. -- ์ ๋์ค์ ์คํ๊ฒฐ๊ณผ๊ฐ ๊ฐ๊ฐ ๋ค๋ฆ.
-- LIKE % _
SELECT * FROM EMP WHERE ENAME LIKE 'S%'; -- 1๋ฒ ์๋ฏธ S๋ก ์์ํ๋ ๊ฒ
SELECT * FROM EMP WHERE ENAME LIKE '%S'; -- 2๋ฒ ์๋ฏธ S๋ก ๋๋๋ ๊ฒ
SELECT * FROM EMP WHERE ENAME LIKE '%S%';
SELECT * FROM EMP WHERE ENAME LIKE 'S____'; -- 3๋ฒ _๋ 4๊ฐ S๋ก ์์ํ๋ 5๊ธ์
SELECT * FROM EMP WHERE ENAME LIKE '____S'; -- 4๋ฒ _๋ 4๊ฐ S๋ก ๋๋๋ 5๊ธ์
':: DBMS ๐ฉ > OracleDB' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[DBMS] SQL - ๊ฐ๋ - 3 - [SQL - TCL / SQL - DCL] (0) | 2021.03.23 |
---|---|
[DBMS] SQL -7- [SELECT, COMMIT] (0) | 2021.03.22 |
[DBMS] SQL -5- [INSERT, UPDATE, DELETE] (0) | 2021.03.22 |
[DBMS] SQL ๊ฐ๋ -2- "E-R๋ชจ๋ธ, ์ ๊ทํ, ์ํ์ค ( Sequence )" (0) | 2021.03.22 |
[DBMS] - 4 - SQL - DROP, TRUNCATE (0) | 2021.03.16 |
๋๊ธ