[Daily] MySQL pre-processing technology testing, mysql pre-processing
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 transmitted in sequence