MySQL pre-processing technology usage Test

Source: Internet
Author: User

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

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.