回答編集履歴

3

chousei

2022/06/22 10:39

投稿

yambejp
yambejp

スコア114883

test CHANGED
@@ -16,7 +16,9 @@
16
16
  (4,2,3,0),
17
17
  (5,1,2,0),
18
18
  (5,2,1,1);
19
-
19
+ ```
20
+ として、
21
+ ```SQL
20
22
  select * from replay as t1
21
23
  where (select 1
22
24
  from replay

2

chousei

2022/06/22 10:38

投稿

yambejp
yambejp

スコア114883

test CHANGED
@@ -24,3 +24,12 @@
24
24
  having group_concat(chra_id order by chra_id asc)='1,2'
25
25
  and replay_id=t1.replay_id);
26
26
  ```
27
+ もしくは
28
+ ```SQL
29
+ select * from replay as t1
30
+ where (select 1
31
+ from replay
32
+ group by replay_id
33
+ having sum(chra_id in(1,2))=2
34
+ and replay_id=t1.replay_id);
35
+ ```

1

chousei

2022/06/22 10:16

投稿

yambejp
yambejp

スコア114883

test CHANGED
@@ -1,6 +1,10 @@
1
1
  ```SQL
2
2
  create table replay(
3
+ replay_id int,
4
+ player_type int,
5
+ chra_id int,
6
+ win_flag int,
3
- replay_id int,player_type int,chra_id int,win_flag int,unique(replay_id,player_type));
7
+ unique(replay_id,player_type));
4
8
  insert into replay values
5
9
  (1,1,1,1),
6
10
  (1,2,2,0),