MYSQL Unknown Column Solution

Source: Internet
Author: User
Tags knowledge base

Solution:

There are a lot of users who use MySQL may encounter this problem, obviously the table in this column exists, why in the query when said that the column name can not be found?

The reason I came across is that the column names are preceded by spaces:

Create TableStudents (SIDint, _mathdecimal(9,2), 中文版varchar(3) );Insert  intoStudentsValues(1, -,' -'),(2, -,' -'),(3, the,' the'),(4,NULL,' the'),(5, the,NULL),(6,NULL,NULL); MySQL> Select *  fromstudents;+---------+-----------+-------------+|Sid|_math|中文版|+---------+-----------+-------------+|       1 |     50.00 |  -          ||       2 |     70.00 |  -          ||       3 |     80.00 |  the          ||       4 |      NULL |  the          ||       5 |     80.00 | NULL        ||       6 |      NULL | NULL        |+---------+-----------+-------------+Select *not easy to see the problem, we use show create to see:|Students| CREATE TABLE' Students ' (' Sid ' )int( One)DEFAULT NULL, ' _math 'decimal(9,2)DEFAULT NULL, ' 中文版 'varchar(3)DEFAULT NULL) ENGINE=InnoDBDEFAULTCHARSET=Utf8|There are many more spaces in front of each column name. Solution, remove table rebuild:Drop Tablestudents; cause of error:1, it is possible that the code you created the table is copy online. For example, the one I entered above creates a table with a statement that will cause problems. 2, your editor is recognized as a Chinese space. It is generally not possible to enter this issue in Notepad. 

mysql5.x Manual http://doc.mysql.cn/
MySQL official website http://dev.mysql.com/
Mysql5.7 Reference Manual http://dev.mysql.com/doc/refman/5.7/en/
Other reference Manuals
Csdn-mysql Knowledge Base

Author:liuning

MYSQL Unknown Column Solution

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.