Skip to content

Instantly share code, notes, and snippets.

@honux77 honux77/sample.sql
Created May 22, 2017

Embed
What would you like to do?
CREATE TABLE PROF(
PID INT PRIMARY KEY,
NAME VARCHAR(16));
CREATE TABLE STU (
ID INT PRIMARY KEY,
NAME VARCHAR(16),
PID INT,
FOREIGN KEY (PID) REFERENCES PROF(PID)
);
INSERT INTO PROF VALUES (1, 'SM9'), (2, 'JJ'), (3, 'HONUX');
INSERT INTO STU VALUES (1, 'AA', 1), (2, 'BB', 2), (3, 'CC', 3), (4, 'DD', 1), (5, 'EE', 2);
SELECT * FROM STU S
JOIN PROF P
ON S.PID <> P.PID WHERE P.NAME = 'SM9';
SELECT * FROM STU S
JOIN PROF P
ON S.PID = P.PID WHERE P.NAME <> 'SM9';
@honux77

This comment has been minimized.

Copy link
Owner Author

commented May 22, 2017

셀렉트 1의 결과
2, .., 1, ...
3, .., 1, ...
5, .., 1, ...

셀렉트 2의 결과

2, ..., 2, ...
3, ..., 3, ...
5, ..., 3, ...

으로 두 쿼리 모두 선택되는 학생 레코드는 동일합니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.