Solutions to conflicts between field names and reserved words in MySQL

Source: Internet
Author: User

We know that the general SQL query statement is written as follows:

Copy codeThe Code is as follows: select col from table;

Of course this is okay, but what if the field name is "from?

Copy codeThe Code is as follows: select from table;

If this is true, an error is inevitable. When the field name conflicts with the reserved MySQL words, you can use the character "'" to enclose the field name:

Copy codeThe Code is as follows: select 'from' from table;


Summary

I just found that two fields in my original database table use reserved words (add, comment ). An error occurred during insert and update. I remember that SQL server seems to be surrounded. So I tried it and it turns out that it won't work in mySql. After a simple search on the Internet, we found that brackets were used. Later, I thought that the SQL statement generated by MySql Administrator would enclose all the table names in single quotes. After trying it out, it still won't work. But the generated symbol can be copied. Make sure that the symbol is not a single quotation mark. The marker ('is the key on the front of number 1 ). Solve this problem. The following is a summary:

In Mysql, when the table name, field name, or Database Name Conflict with the reserved word, you can use the marker (') in an SQL statement.

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.