回答編集履歴
9
コード修正
answer
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
select seq, count(col2)
|
4
4
|
from
|
5
5
|
(select col2 from testtable1 where col1 = 'Tanaka') t
|
6
|
-
right join (select
|
6
|
+
right join (select seq from seq_0_to_9) s on t.col2 = s.seq
|
7
7
|
group by seq
|
8
8
|
;
|
9
9
|
```
|
8
コード修正
answer
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
MariaDB 10.1 以降なら、これでいけるはず。[
|
1
|
+
MariaDB 10.1 以降なら、これでいけるはず。[Sequence Storage Engine](https://mariadb.com/kb/en/library/sequence-storage-engine/)
|
2
2
|
```sql
|
3
3
|
select seq, count(col2)
|
4
4
|
from
|
5
|
-
(select
|
5
|
+
(select col2 from testtable1 where col1 = 'Tanaka') t
|
6
6
|
right join (select * from seq_0_to_9) s on t.col2 = s.seq
|
7
7
|
group by seq
|
8
8
|
;
|
7
コード修正
answer
CHANGED
@@ -1,1 +1,9 @@
|
|
1
|
+
MariaDB 10.1 以降なら、これでいけるはず。[シーケンスストレージエンジン](https://mariadb.com/kb/en/library/sequence-storage-engine/)
|
2
|
+
```sql
|
1
|
-
|
3
|
+
select seq, count(col2)
|
4
|
+
from
|
5
|
+
(select * from testtable1 where col1 = 'Tanaka') t
|
6
|
+
right join (select * from seq_0_to_9) s on t.col2 = s.seq
|
7
|
+
group by seq
|
8
|
+
;
|
9
|
+
```
|
6
削除
answer
CHANGED
@@ -1,9 +1,1 @@
|
|
1
|
-
MariaDB 10.1 以降なら、これでいけるはず。[シーケンスストレージエンジン](https://mariadb.com/kb/en/library/sequence-storage-engine/)
|
2
|
-
```sql
|
3
|
-
|
1
|
+
まともに動かないコードだったので削除します。
|
4
|
-
from test1
|
5
|
-
right join (SELECT * FROM seq_0_to_9) s on test1.col2 = seq
|
6
|
-
where col1 = 'Tanaka' or col1 is null
|
7
|
-
group by seq
|
8
|
-
;
|
9
|
-
```
|
5
コード修正
answer
CHANGED
@@ -5,4 +5,5 @@
|
|
5
5
|
right join (SELECT * FROM seq_0_to_9) s on test1.col2 = seq
|
6
6
|
where col1 = 'Tanaka' or col1 is null
|
7
7
|
group by seq
|
8
|
+
;
|
8
9
|
```
|
4
コード修正
answer
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
```sql
|
3
3
|
select seq, count(col2)
|
4
4
|
from test1
|
5
|
-
right join (SELECT * FROM seq_0_to_9)
|
5
|
+
right join (SELECT * FROM seq_0_to_9) s on test1.col2 = seq
|
6
6
|
where col1 = 'Tanaka' or col1 is null
|
7
7
|
group by seq
|
8
8
|
```
|
3
コード修正
answer
CHANGED
@@ -4,5 +4,5 @@
|
|
4
4
|
from test1
|
5
5
|
right join (SELECT * FROM seq_0_to_9) as seq on test1.col2 = seq.seq
|
6
6
|
where col1 = 'Tanaka' or col1 is null
|
7
|
-
group by seq
|
7
|
+
group by seq
|
8
8
|
```
|
2
コード修正
answer
CHANGED
@@ -1,1 +1,8 @@
|
|
1
|
+
MariaDB 10.1 以降なら、これでいけるはず。[シーケンスストレージエンジン](https://mariadb.com/kb/en/library/sequence-storage-engine/)
|
2
|
+
```sql
|
1
|
-
|
3
|
+
select seq, count(col2)
|
4
|
+
from test1
|
5
|
+
right join (SELECT * FROM seq_0_to_9) as seq on test1.col2 = seq.seq
|
6
|
+
where col1 = 'Tanaka' or col1 is null
|
7
|
+
group by seq,col1
|
8
|
+
```
|
1
削除
answer
CHANGED
@@ -1,10 +1,1 @@
|
|
1
|
-
性能度外視です。
|
2
|
-
```sql
|
3
|
-
set @count = -1;
|
4
|
-
select seq.no, count(col2) - 1 as count
|
5
|
-
from testtable1
|
6
|
-
join (select @count := @count + 1 as no from testtable1 limit 10) as seq on testtable1.col2 = seq.no
|
7
|
-
where col1 = 'Tanaka'
|
8
|
-
|
1
|
+
まともに走らないコードだったので削除します。
|
9
|
-
;
|
10
|
-
```
|