Skip to content

Instantly share code, notes, and snippets.

@honux77
Created May 22, 2017 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save honux77/babcf9a7b24c4e5acdee32c7fad2a1ef to your computer and use it in GitHub Desktop.
Save honux77/babcf9a7b24c4e5acdee32c7fad2a1ef to your computer and use it in GitHub Desktop.
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
Copy link
Author

honux77 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