set @XX=‘‘; SELECT @XX := CONCAT( @XX, ID , ‘,‘ ) FROM (SELECT DISTINCT ID FROM TX) A; set @YY = CONCAT(‘SELECT TX.*,‘,LEFT(@XX,LENGTH(@XX)-1),‘ FROM TX ‘); PREPARE stmt2 FROM @YY; EXECUTE stmt2;
时间: 2024-11-07 15:01:37
set @XX=‘‘; SELECT @XX := CONCAT( @XX, ID , ‘,‘ ) FROM (SELECT DISTINCT ID FROM TX) A; set @YY = CONCAT(‘SELECT TX.*,‘,LEFT(@XX,LENGTH(@XX)-1),‘ FROM TX ‘); PREPARE stmt2 FROM @YY; EXECUTE stmt2;