1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
USE plato; $data = select key, subkey, value from Input group by GROUPING SETS ( (key, subkey), (subkey, value) ); INSERT INTO @tmp WITH TRUNCATE SELECT b.value FROM $data AS a LEFT JOIN Input AS b USING (key)