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