I. Problems
To generate two types of data:
Class A: 01 02 03 of two digits... 09 10 11... 19 20 21... 98 99
Another Class B: The third-digit 100 101 102... 110 111 112... 998 999
Ii. Solution
1. Create a table
CopyCode The Code is as follows: Create Table 'test'. 'ta '(
'A' varchar (45) not null
) Engine = InnoDB default charset = utf8;
2. Create a stored procedureCopy codeThe Code is as follows: delimiter $
Drop procedure if exists 'test'. 'proc _ TP '$
Create definer = 'root' @ 'localhost' procedure 'proc _ TP '(in prex int, in 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. respectively call and execute the Stored Procedure
Call proc_tp () to create Class A Data
Call proc_tp (10,100) to create Class B data
4. query results
Select * From ta t order by cast (A as signed) ASC;