-3

How can I display the following SQL query's results in PHP ?

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;
tux3
  • 7,171
  • 6
  • 39
  • 51

1 Answers1

0
Community
  • 1
  • 1
Michael Jaros
  • 4,586
  • 1
  • 22
  • 39