Usage of single and double quotation marks in mysql, and double quotation marks in mysql

Source: Internet
Author: User

Usage of single and double quotation marks in mysql, and double quotation marks in mysql

The table name and column name are preferably '(the one under esc, not' will cause an error)

This should start with double quotation marks and single quotes:
Fields in double quotation marks are interpreted by the compiler and then output as HTML code. However, fields in single quotation marks do not need to be interpreted and are directly output. For example:
$ Abc = 'I love U ';
Echo $ abc // The result is: I love u
Echo '$ abc' // The result is: $ abc
Echo "$ abc" // The result is: I love u
Therefore, when assigning values to SQL statements in the database, use SQL = "select a, B, c from..." in double quotation marks ..."
However, the SQL statement quotes the field name.
Example: select * from table where user = 'abc ';
The SQL statement here can be directly written as SQL = "select * from table where user = 'abc '"
However, if it is as follows:
$ User = 'abc ';
SQL1 = "select * from table where user = '". $ user. "'"; Comparison
SQL2 = "select * from table where user = 'abc '"
I add spaces between single quotes and double quotes. I hope you can see it clearly.
That is, replacing 'abc' with '". $ user."' is in a single quotation mark. It only splits the entire SQL string.
SQL1 can be divided into the following three parts:
1: "select * from table where user = '"
2: $ user
3 :"'"
Use. To connect strings.

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.