mysql 分组查询一样的内容放在一起,循环新增测试

2021-11-15 13:59:05   MYSQL

 

#分组查询

SELECT score,GROUP_CONCAT(name) as name FROM esg_test GROUP BY score ORDER BY score desc 



#循环测试

DELIMITER ;

CREATE PROCEDURE test_insert()

BEGIN

DECLARE y int(10) DEFAULT 1;

WHILE y<1000

DO

INSERT INTO esg_test(name,score) VALUES ("a"+y,FLOOR(1 + (RAND() * 1)));

SET y=y+1;

END WHILE ;

commit;

END;

CALL test_insert();