回答編集履歴

3

修正

2018/07/10 14:25

投稿

sazi
sazi

スコア25300

test CHANGED
@@ -36,7 +36,7 @@
36
36
 
37
37
  ---
38
38
 
39
- 質問の追記に対する追記
39
+ 質問の追記に対する追記※修正
40
40
 
41
41
  ```SQL
42
42
 
@@ -44,13 +44,11 @@
44
44
 
45
45
  from hoge
46
46
 
47
- where case tmp
47
+ where (
48
48
 
49
- when '1' then ID='1'
49
+ (tmp='1' and ID='1') or (tmp='2' and ID in ('2','3'))
50
50
 
51
- when '2' then ID in ('2','3')
52
-
53
- end
51
+ )
54
52
 
55
53
  and name = 'name_1';
56
54
 

2

追記

2018/07/10 14:25

投稿

sazi
sazi

スコア25300

test CHANGED
@@ -31,3 +31,27 @@
31
31
  end
32
32
 
33
33
  ```
34
+
35
+ 追記
36
+
37
+ ---
38
+
39
+ 質問の追記に対する追記
40
+
41
+ ```SQL
42
+
43
+ select id into hoge
44
+
45
+ from hoge
46
+
47
+ where case tmp
48
+
49
+ when '1' then ID='1'
50
+
51
+ when '2' then ID in ('2','3')
52
+
53
+ end
54
+
55
+ and name = 'name_1';
56
+
57
+ ```

1

推敲

2018/07/10 13:45

投稿

sazi
sazi

スコア25300

test CHANGED
@@ -26,7 +26,7 @@
26
26
 
27
27
  case when tmp='1' then '1'
28
28
 
29
- when tmp = '2' or tmp='3' then '2'
29
+ when tmp='2' or tmp='3' then '2'
30
30
 
31
31
  end
32
32