Background description
Test requirements: For example, to filter by the number of pre-ordered organizations, ranked 51st and after the organization does not show.
Before verifying the function, there are at least 50 different appointments in the test data,
Implementation method:
1. Or manually inserted into the database table, 50 organizations to add a different number of appointments, to add, side record the number of appointments.
2. Generate data in a certain pattern and insert it into a database table.
3. Loop through the data with the SQL statement (find the rules in advance)
--------------------------------------------------------------------------------------------------------------- ------
Institution Reservation record form
Id+1 User ID can be unchanged mobile phone number can be unchanged agency ID (after adding the number of appointments to the organization, the organization ID to change, that is, to add the number of appointments to other organizations)
1 623182 15228*****64 1 0 0 2018-06-14 18:33:44 2 018-06-14 18:33:44
#DELIMITER # CREATE PROCEDURE test_fi () BEGIN DECLARE ID int default 2384; #主键 #declare institition_id int default 978; #机构id #declare num int default ; #为N个机构创建预约记录, the number of appointments per institution is n#declare temp int default 0; #temp被赋值为N, create n number of appointments # #为N个机构创建预约记录 for your organization, with an appointment of N#while num>0 doset temp=num;while temp>0 doinsert into reservation per institution _apply values (ID, ' 722619 ', ' 13513111311 ', institition_id, ', ', ', 0, ', 0, ', ' 2018-6-30 14:47:51 ', ' 2018-6-30 14:47:58 ') ; set id=id+1; SET temp=temp-1;end While;set num=num-5; SET institition_id = institition_id-5; END while; END call Test_fi ();
# INSERT INTO reservation_apply values (2224, ' 722619 ', ' 13511111111 ', 100, ', ', ', 0, ' ', 0, ', ' 2018-6-30 14:47:51 ', ' 2018-6-30 14:47:55 '); The result of the operation is OK #
About MySQL stored procedures, this is the tip of the iceberg, but also continue to learn.
Test by the 1th way to build data, later in the 3rd way to build data, this contrast is too obvious, saving time and effort. ??
Looping data in MySQL--build test data