- SELECT CASE(조건혹은 값)
- WHEN 값 1 THEN 표시해줄값
- WHEN 값 2~ THEN 표시해줄값
- END
- 식으로 사용
- THEN에도 쿼리문식으로 값을 리턴해줄수 있다
- 점점 고오급 쿼리가 되가는듯?
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
|
case (조건 또는 값)
when 값1 then 표시값
when 값2 then 표시값
else 표시값
end;
select
(SELECT CASE
(info.p_info_seq)
WHEN 1 THEN
(select
store.st_name
from d_coupon_useInfo useInfo
join d_coupon coupon on (coupon.cp_seq = useInfo.cp_seq)
join d_store store on (store.st_seq = coupon.st_seq)
where useInfo.seq=log2.p_ref_seq )
END FROM d_point_info as info) AS 'loc',
info2.isPlus,
log2.p_point,
log2.createDate,
u.address2
from d_point_log log2
join d_point_info info2 on (info2.p_info_seq = log2.p_info_seq)
join d_user u on (u.seq = log2.user_seq)
where log2.user_seq=123
order by log2.createDate desc;
| cs |
ㅇ
댓글 없음:
댓글 쓰기