메뉴 건너뛰기

조회 수 138 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

-- select 명령문의 조합 

 

 

-- 학년이 2, 3 학년인 학생의 학번과 이름을 출력하라

select stu_no, stu_name,grade from student where grade in (2 ,3);

 

 

select stu_no, stu_name,grade

from student

where grade = 2

union

select stu_no, stu_name,grade

from student

where grade = 3

 

 

 

-- 적어도 한번 이상 수강신청을 했거나 등록을 한 학생의 학번을 출력하라 

 

select stu_no 

from attend

union

select stu_no

from fee;

 

 

-- 적어도 한번 동아리에 가입했거나,

-- 등록을 하고 그리고 수강신청을 한 학생 중에서

-- 이상의 조건 중 둘 또는 세가지 조건을 만족하는 또는 두개의 조건에 모두 포함되는 각 학생의 학번을 출력하라 

 

 

-- (x)

select stu_no from attend where stu_no in 

(select stu_no from circle

union

select stu_no from fee

);

 

-- (o)

 

select stu_no from circle

union

select stu_no from fee

union 

select stu_no

from attend

where att_div='Y';

 

 

-- 적어도 한번 이상 등록금 납부하고 동아리에 가입한 모든 학생을 출력하라 

-- (단 중복된 행을 제거하지 않고 모두 출력한다. )

 

select stu_no from fee 

UNION all

select stu_no from circle;

 

-- 20061011 학생과 20071307 학생이 받은 장학금액을 출력하라

 

 

select stu_no ,jang_total 

from fee

where stu_no in (20061011, 20071307);

 

 

 

select stu_no, jang_total

from fee

where stu_no =20061011

union

select stu_no, jang_total

from fee

where stu_no =20071307;

 

 

-- -------------------------------------------------------

 

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
-- select 명령문의 조합 
 
 
-- 학년이 2, 3 학년인 학생의 학번과 이름을 출력하라
select stu_no, stu_name,grade from student where grade in (2 ,3);
 
 
select stu_no, stu_name,grade
from student
where grade = 2
union
select stu_no, stu_name,grade
from student
where grade = 3
 
 
 
-- 적어도 한번 이상 수강신청을 했거나 등록을 한 학생의 학번을 출력하라 
 
select stu_no 
from attend
union
select stu_no
from fee;
 
 
-- 적어도 한번 동아리에 가입했거나,
-- 등록을 하고 그리고 수강신청을 한 학생 중에서
-- 이상의 조건 중 둘 또는 세가지 조건을 만족하는 또는 두개의 조건에 모두 포함되는 각 학생의 학번을 출력하라 
 
 
-- (x)
select stu_no from attend where stu_no in 
(select stu_no from circle
union
select stu_no from fee
);
 
-- (o)
 
select stu_no from circle
union
select stu_no from fee
union 
select stu_no
from attend
where att_div='Y';
 
 
-- 적어도 한번 이상 등록금 납부하고 동아리에 가입한 모든 학생을 출력하라 
-- (단 중복된 행을 제거하지 않고 모두 출력한다. )
 
select stu_no from fee 
UNION all
select stu_no from circle;
 
-- 20061011 학생과 20071307 학생이 받은 장학금액을 출력하라
 
 
select stu_no ,jang_total 
from fee
where stu_no in (2006101120071307);
 
 
 
select stu_no, jang_total
from fee
where stu_no =20061011
union
select stu_no, jang_total
from fee
where stu_no =20071307;
 
 
-- -------------------------------------------------------


 


List of Articles
번호 제목 날짜 조회 수
126 mysql table 값 변경 mariadb 테이블 값 변경 2023.01.12 83
125 FORMAT 문법 사용 하기(숫자 자리수 나타내기) file 2023.01.10 98
124 MYSQL IN&BETWEEN&NULL&예제&FROM절 문제3 file 2021.03.27 104
123 MYSQL any&all&in&예제& WHERE 절 문제4 file 2021.03.27 111
122 CASE 문법 사용 하기 file 2023.01.10 111
121 데이터베이스별 / 테이블별 용량 확인 하기 2023.01.10 115
120 mysql-bin(binary log)파일 정리 및 삭제 2023.01.12 117
119 MYSQL Groupby & having 예제 문제 6 file 2021.03.27 118
118 no exists, not in 을 이용한 조건에 만족하지 않는 것들 구하기, 둘의 차이점 2021.03.26 125
117 fulltext 관련 글 2021.03.26 125
116 MYSQL order by 예제&문제 7 file 2021.03.27 126
115 column의 정보 중에서 column 설명(column_comment) 2021.03.26 129
114 binlog 조회 / 삭제 / 보관 기간 설정 file 2023.01.10 129
113 MYSQL FULLTEXT INDEX & PARTION 검색기능향상&파티션 file 2021.03.27 131
112 MYSQL 부속질의어 예제&문제 9 file 2021.03.27 134
111 MYSQL 기초문법&예제&문제 2 file 2021.03.27 136
110 MYSQL 통계 함수 SUM AVG MAX MIN 예제 문제 5 file 2021.03.27 137
» MYSQL select 명령문의 조합 &union 예제&문제 8 file 2021.03.27 138
108 MariaDB can't create test file lower-test 2023.02.16 139
107 엑셀로 되어있는 부분 db로 import하는 방법 2020.07.28 144
Board Pagination Prev 1 2 3 4 5 6 7 Next
/ 7

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved