MySQL and MSSQl use the While statement to generate test data cyclically _ MySQL
Source: Internet
Author: User
In MySQL, the code bitsCN.com that uses the While statement to generate test data cyclically is different from that in SQL Server. the code passes the test.
In MSSQL, the while statement is used to generate data cyclically:
Sample code:
Declare @ a int
Set @ a = 1
While @ a <25
Begin
Insert into demotable (id, item1, item2) VALUES (@ a, "abc", "123 ")
Set @ a = @ a + 1
End
In MySQL, the while loop is used to process data: you need to create a stored procedure and directly call and execute the stored procedure.
Sample code:
Create definer = 'root' @ 'localhost' PROCEDURE 'newprocedure '()
BEGIN
DECLARE I INT;
SET I = 1;
WHILE I & lt; 100 DO
Insert into demotable (id, item1, item2) VALUES (I, "Test Question", "0 ");
SET I = I + 1;
End while;
END;
BitsCN.com
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.