JOIN문, VIEW 생성
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | CREATE TABLE T1 ( A INT PRIMARY KEY, B VARCHAR(20) ) INSERT INTO T1 (A,B) VALUES (1,'김대중') INSERT INTO T1 (A,B) VALUES (2,'김영삼') INSERT INTO T1 (A,B) VALUES (3,'노태우') INSERT INTO T1 (A,B) VALUES (4,'전두환') CREATE TABLE T2 ( A INT PRIMARY KEY, C VARCHAR(20) ) INSERT INTO T2 (A,C) VALUES (2,'SM5') INSERT INTO T2 (A,C) VALUES (3,'SONATA') --INNER JOIN SELECT T1.A, T1.B, T2.C FROM T1 INNER JOIN T2 ON T1.A=T2.A --T-SQL SELECT T1.A,T1.B, T2.C FROM T1 , T2 WHERE T1.A = T2.A --LEFT OUTER JOIN : 좌측을 기준 --ANSI SQL SELECT T1.A,T1.B, T2.C FROM T1 LEFT OUTER JOIN T2 ON T1.A=T2.A SELECT T1.A,T1.B, T2.C FROM T1 FULL OUTER JOIN T2 ON T1.A=T2.A CREATE VIEW TEMPBASEVIEW AS SELECT T1.A,T1.B, T2.C FROM T1 LEFT OUTER JOIN T2 ON T1.A=T2.A SELECT * FROM TEMPBASEVIEW |
'RDBMS(mysql,mssql)' 카테고리의 다른 글
복제DB(replication db) 와 Bulk Insert (0) | 2020.06.20 |
---|---|
[MSSQL][펌] 인덱스 성능차이 실습 (0) | 2018.08.03 |
[MSSQL] 다수의 데이터 INSERT (0) | 2018.08.03 |
[MSSQL] 14.트리거,커서 (Trigger, Cursor) (0) | 2018.08.01 |
[MSSQL] 15.인덱스(INDEX) (0) | 2018.08.01 |