반응형
use study_exam2
SELECT * ---- 33번
FROM
Student, MAJOR -- student=부모, major= 자식
WHERE student.MajorCode = 1 AND
major.majorCode =1
SELECT * FROM --33번
Student AS s, Major AS m
WHERE s.MajorCode = m.MajorCode AND -- 네츄럴 조인
m.MajorName='컴퓨터공학과'
SELECT * FROM --33번
Student AS s INNER JOIN Major AS m
ON s.MajorCode = m.MajorCode AND -- 이너조인
m.MajorName='컴퓨터공학과'
SELECT * ----- 34번
FROM
student, major
WHERE student.majorcode= 2 AND
major.majorcode=2
SELECT * FROM STUDENT A, MAJOR B -- 34번
WHERE A.MajorCode = B.MajorCode AND B.MajorCode = '02'
////////////////////// 35번 문제 /////////////////////
-- 35번 문제
SELECT s.name, ssub.subjectcode, sub.SubjectName
FROM student AS s, student_subject AS ssub , subject AS sub
WHERE s.sno=0727001
-- 1
SELECT *
FROM
student AS a, student_subject AS B
WHERE a.sno = 0727001
-- 2
SELECT *
FROM
student AS a, student_subject AS B
WHERE a.sno = b.sno
AND a.sno = 0727001
-- 3
SELECT a.name, b.subjectcode
FROM
student AS a, student_subject AS B
WHERE a.sno = b.sno
AND a.sno = 0727001
-- 4
SELECT a.name, b.subjectcode, c.subjectname
FROM
student AS a, student_subject AS B , subject AS c
WHERE a.sno = b.sno
AND b.subjectcode = c.subjectcode
AND a.sno = 0727001
-- 이너조인
SELECT a.name, b.subjectcode, c.subjectname
FROM student AS a INNER JOIN student_subject AS B
ON a.sno= b.sno INNER JOIN subject AS c
ON b.subjectcode = c.subjectcode
WHERE a.sno = 0727001
'Database > MS-SQL' 카테고리의 다른 글
저장프로시저와 사용자 지정함수 사용예 (0) | 2008.10.14 |
---|---|
데이터 베이스 LOCK(잠금) DEAD LOCK(교착상태) (0) | 2008.10.14 |
쿼리문 실행 예제 (2) | 2008.10.14 |
데이터베이스 트렌젝션 TRAN 예제 (0) | 2008.10.14 |
셀렉트문 팁 SELECT 28번 문제설명 + 서브 쿼리 중요 (0) | 2008.10.13 |
DATEBASE 쿼리 문제 실습 19~31 (0) | 2008.10.13 |
TABLE에서 행을 삭제하는 세 가지 OPTION의 비교 DELETE TRUNCATE DROP 과 CREATE (0) | 2008.10.10 |
DATEBASE 쿼리 문제 실습 - 오픈과제 01.doc (0) | 2008.10.10 |