I have a mariadb table where i want to turn the distinct values of a column to turn to columns
the table is a0_biologika and fields are
id = int AUTO_INCREMENT (primary key)
afm = varchar(9) not null
etos = varchar(4) not null
i found sql code that works in phpMyAdmin. The code is
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'ifnull(SUM(case when etos= ''',
etos,
''' then 1 end),0) AS ',
etos, '
'
)
) INTO @sql
FROM
a0_biologika ;
SET @sql = CONCAT('SELECT afm, ', @sql, '
FROM a0_biologika
GROUP BY afm);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
This code produces a view with column afm and every distinct value of column etos as separate column with value 1 if exist or 0 if not
How to transfer it to PHPRunner? I think from Create SQLView but it produces a syntax error. Because it runs in phpMyAdmin i cant find the error.