我试图在phpMyAdmin来执行这个代码。 但是,我发现了以下错误
赋予执行未知事先准备好的声明处理器(语句) - #1243
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'count(distinct CASE WHEN topic = ''',
topic,
''' THEN t2.id END) AS `',
topic, '`'
)
) INTO @sql
FROM
(
select count(distinct id) total, topic
from table2
group by topic
order by total desc
limit 2
) d;
SET @sql
= CONCAT('SELECT t1.year, ', @sql, '
from table1 t1
left join table2 t2
on t1.id = t2.id
group by t1.year');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
退房小提琴实施。
如何解决这一问题? 此外,作为一个COM导师时提到通过脚本发送这会工作。 任何想法我怎么脚本PHP?