What is the role of "'" in SQL?

Source: Internet
Author: User
Keywords sql php
See someone else's code,

'SELECT '.$param['field'].' FROM `'.DBPRE.$param['table']

What does the sign from the back of the function do?

Reply content:

See someone else's code,

'SELECT '.$param['field'].' FROM `'.DBPRE.$param['table']

What does the sign from the back of the function do?

All databases have similar settings, but MySQL uses ' just '. This is typically used to describe the database name, table name, and field name. For example

select from from table;

The first from is the field name, the last table is also the field name, but it is also the MySQL keyword, so the execution will be error, so you should use

select `from` from `table`

Of course, for readability, it is not recommended to use the keyword as the field name, the table name, and the database name, table name, field name should be included in a pair of anti-quotes.

Avoid conflict with the keyword, is to tell MySQL inside is a normal string, not what command

Avoid conflicts with MySQL's own keyword, so use this notation, although sometimes it doesn't affect the query but it's better to add it.

  • 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.