MySQL pre-processing technology usage Test
MySQL Preprocessing Technology:
1. Reduce server pressure
2. Prevent SQL injection. Pass the dangerous characters in the past as parameters.
3. Forcibly split an SQL statement into two parts: the first part is the same command and structure, and the second part is the variable data.
Basic usage
Prepare SQL _1 from "select * from mass_list ";
Execute SQL _1;
Drop prepare SQL _1;
Parameter passing:
Prepare SQL _2 from "select * from mass_list where id =? ";
Set @ id = 1;
Execute SQL _2 using @ id;
Prepare SQL _3 from "insert into mass_list (mass_name) values (?) ";
Set @ name = 'zhang ';
Execute SQL _3 using @ name;
Prepare SQL _3 from "insert into mass_list (mass_name, user_email_id) values (?,?), (?,?) ";
Set @ name = 'zhang ';
Set @ id = 1;
Execute SQL _3 using @ name, @ id, @ name, @ id; // parameters are passed in order
This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151363.htm