SET @q = 'SELECT ';
SET @i = 0;
WHILE @i < 100 DO
SET @q = CONCAT(@q, 'ROUND(col_',@i,',2), ');
SET @i = @i + 1;
END WHILE;
SET @q = CONCAT(SubStr(@q, 1, LENGTH(@q) - 2),' FROM TABLE_NAME');
PREPARE stmt FROM @q;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
1条答案
按热度按时间qkf9rpyu1#
如果你想避免代码中的重复,这里有一个100列的技巧:
你需要把它放在一个程序上,然后调用它。