如何在 phpmyadmin 中使用准备好的语句?我有一个 sql 查询,但是当我运行它时,它只显示一条消息,例如我的查询已成功执行。我看不到结果。请帮忙。
我的 sql 查询是
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'max(case when exam = ''',
exam,
''' then student end) AS `',
exam, '`'
)
) INTO @sql
from yourtable;
SET @sql
= CONCAT('SELECT ', @sql, '
from yourtable
group by id;');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;