在php中显示sql查询结果

时间:2015-03-06 17:56:25

标签: php

如何在PHP中显示以下SQL查询的结果?

SELECT CONCAT(
'SELECT `repagents`.full_name', GROUP_CONCAT('
, `t_', REPLACE(status, '`', '``'), '`.value
AS `', REPLACE(status, '`', '``'), '`'
SEPARATOR ''),
' FROM `repagents` ', GROUP_CONCAT('
LEFT JOIN `repagents` AS `t_', REPLACE(status, '`', '``'), '`
ON `repagents`.full_name = `t_', REPLACE(status, '`', '``'), '`.full_name
AND `t_', REPLACE(status, '`', '``'), '`.status = ', QUOTE(status)
SEPARATOR ''),
' GROUP BY `repagents`.full_name'
) INTO @qry FROM (SELECT DISTINCT status FROM `repagents`) t;
PREPARE stmt FROM @qry;
EXECUTE stmt;

1 个答案:

答案 0 :(得分:0)

相关问题