I. Problems
To generate two types of data:
Class A: two-digit 01 02 03 ... 09 10 11 ... 19 20 21 ... 98 99
Another class B: three-digit 100 101 102 ... 110 111 112 ... 998 999
Ii. Solutions
1, build the table
Copy Code code as follows:
CREATE TABLE ' test '. ' Ta ' (
' A ' varchar not NULL
) Engine=innodb DEFAULT Charset=utf8;
2. Create a stored procedure
Copy Code code as follows:
DELIMITER $$
DROP PROCEDURE IF EXISTS ' test '. ' Proc_tp ' $$
CREATE definer= ' root ' @ ' localhost ' PROCEDURE ' proc_tp ' (in Prex Max int)
Begin
Declare i INT DEFAULT 0;
DECLARE s varchar (500);
while (I<10 and Prex<max) do
Select Concat (prex,i) into S;
INSERT into TA (a) values (s);
Set i=i+1;
if (i=10 and Prex<max) then
Set prex=prex+1;
Set i=0;
End If;
End while;
End $$
DELIMITER;
3. Call execution stored procedure separately
Call PROC_TP (0,10) creates Class A data
Call PROC_TP (10,100) Create Class B data
4. Query results
SELECT * from TA t order by cast (a as signed) ASC;