I have Mysql prepare statement work in command line. how get I get it to work with PHP PDO prepare statement?
set @sql = null;
SET group_concat_max_len=15000;
select group_concat(distinct concat('sum(if(date=''',date_format(date,'%Y-%m-%d'),''',total,null)) as ', date_format(date,'dd%Y%m%d'))) into @sql from sales where date_format(date,'%m%y')='0615';
set @sql = concat('select ',@sql,' from sales');
PREPARE stmt FROM @sql;
EXECUTE stmt;