回答編集履歴
2
追記
test
CHANGED
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
declare continue handler for sqlstate '02000' set done = 1;
|
38
38
|
|
39
|
-
set @a:=(select concat('`',group_concat(distinct d separator '` int null,`'),'` int null') from tbl);
|
39
|
+
set @a:=(select concat('`',group_concat(distinct d order by d asc separator '` int null,`'),'` int null') from tbl);
|
40
40
|
|
41
41
|
set @sql=concat('create temporary table tmp_tbl(`a` int,`b` int,`c` int,',@a,',unique(`a`,`b`,`c`))');
|
42
42
|
|
1
修正
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
効率的かどうかはともかく
|
1
|
+
効率的かどうかはともかく、せっかくなのでプロシージャでやる方法を提示しておきます。
|
2
2
|
|
3
3
|
テーブルの形式が明確ではないのでちょっと簡略化して表示します
|
4
4
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
```
|
14
14
|
|
15
|
-
以下
|
15
|
+
以下プロシージャを作ります
|
16
16
|
|
17
17
|
```sql
|
18
18
|
|
@@ -76,6 +76,8 @@
|
|
76
76
|
|
77
77
|
プロシージャを実行します
|
78
78
|
|
79
|
+
データの追加削除をした後以下を実行すればその時々の状況が確認できます
|
80
|
+
|
79
81
|
```SQL
|
80
82
|
|
81
83
|
call view();
|