CREATE TABLE INFO_TABLE (
INFO_F1 VARCHAR2(10),
INFO_F2 VARCHAR2(20),
INFO_F3 VARCHAR2(20),
COMM_CODE VARCHAR2(10)
)
CREATE TABLE CODE_TABLE (
GROUP_CODE VARCHAR2(10),
COMM_CODE VARCHAR2(10),
COMM_NAME VARCHAR2(20)
)
INFO_TABLE PRIMARY KEY(INFO_F1)
CODE_TABLE PRIMARY KEY(GROUP_CODE, COMM_CODE)
-- 1번
SELECT
A.INFO_F1,
A.INFO_F2,
A.INFO_F3,
B.COMM_CODE,
B.COMM_NAME
FROM INFO_TABLE A
LEFT JOIN (SELECT * FROM CODE_TABLE WHERE GROUP_CODE = 'TEST') B ON (A.COMM_CODE = B.COMM_CODE)
-- 2번
SELECT
A.INFO_F1,
A.INFO_F2,
A.INFO_F3,
B.COMM_CODE,
B.COMM_NAME
FROM INFO_TABLE A
LEFT JOIN CODE_TABLE ON (A.COMM_CODE = B.COMM_CODE AND B.GROUP_CODE = 'TEST')
-- 3번
SELECT
A.INFO_F1,
A.INFO_F2,
A.INFO_F3,
B.COMM_CODE,
B.COMM_NAME
FROM INFO_TABLE A
LEFT JOIN CODE_TABLE ON (A.COMM_CODE = B.COMM_CODE)
WHERE B.GROUP_CODE = 'TEST'
위의 1, 2, 3 쿼리중 어느 쿼리가 가장 좋은 쿼리 인가요?
|