для mariadb 11
CREATE TEMPORARY TABLE temp_table AS
SELECT printer,
CONCAT('{', GROUP_CONCAT(QUOTE(materials)), '}') AS materials
FROM printers
GROUP BY printer;
SELECT CONCAT('{"printer":"', printer, '", "materials":', materials, '}') AS json_format
FROM temp_table;
DROP TEMPORARY TABLE IF EXISTS temp_table;
Получилось вот так
{"printer":"Принтер цвет", "materials":{'A4','A4color','610*175m','610*50m','914*175m','914*50m','A3','A3color'}}
{"printer":"Принтер ч/б", "materials":{'A3','A4'}}
{"printer":"Принтер ч/б и цвет", "materials":{'610*175m','610*175m','914*175m','914*50m'}}