Problems with reserved fields in mysql

  • 2020-10-23 20:19:01
  • OfStack

You have an error in your SQL syntax; This sentence is not new to us, but it is full of ", "and", ". But if you inadvertently add a reserved field from mysql as the name of the field stored in the database, the tragedy happens.

A few days ago, due to the temporary change of function, I needed to add a field to the data table to distinguish the imported batches, so I added the field of group in mysql. I did not expect that my nightmare would start from this
Program is close to ending, this thinking about this morning to the company to the program to the end of the joy, have never thought... every time import excel table always prompts me sql statement is wrong, I'm in sql statement on tian tian relief, also does not have the error, a whole morning plus two hours in the afternoon, it was mad. I was on my knees trying to figure it out, but I still couldn't fix the mistake.
Put the question on the 1 side and move on to something else... I was writing an group by statement when I suddenly realized that group is a reserved word for mysql and the problem was solved. Remember, remember, what a painful realization

Reserved fields for mysql

In MySQL, the words in the following table are retained explicitly. Most of these are used as column and/or table names by the standard SQL (for example, GROUP). A few are retained because MySQL requires them. In MySQL, when the table or field name or even the database name conflicts with a reserved word, the sql statement can be enclosed with an apostrophe (), but let's use these reserved fields as little as possible.

ADD ALL ALTER
ANALYZE AND AS
ASC ASENSITIVE BEFORE
BETWEEN BIGINT BINARY
BLOB BOTH BY
CALL CASCADE CASE
CHANGE CHAR CHARACTER
CHECK COLLATE COLUMN
CONDITION CONNECTION CONSTRAINT
CONTINUE CONVERT CREATE
CROSS CURRENT_DATE CURRENT_TIME
CURRENT_TIMESTAMP CURRENT_USER CURSOR
DATABASE DATABASES DAY_HOUR
DAY_MICROSECOND DAY_MINUTE DAY_SECOND
DEC DECIMAL DECLARE
DEFAULT DELAYED DELETE
DESC DESCRIBE DETERMINISTIC
DISTINCT DISTINCTROW DIV
DOUBLE DROP DUAL
EACH ELSE ELSEIF
ENCLOSED ESCAPED EXISTS
EXIT EXPLAIN FALSE
FETCH FLOAT FLOAT4
FLOAT8 FOR FORCE
FOREIGN FROM FULLTEXT
GOTO GRANT GROUP
HAVING HIGH_PRIORITY HOUR_MICROSECOND
HOUR_MINUTE HOUR_SECOND IF
IGNORE IN INDEX
INFILE INNER INOUT
INSENSITIVE INSERT INT
INT1 INT2 INT3
INT4 INT8 INTEGER
INTERVAL INTO IS
ITERATE JOIN KEY
KEYS KILL LABEL
LEADING LEAVE LEFT
LIKE LIMIT LINEAR
LINES LOAD LOCALTIME
LOCALTIMESTAMP LOCK LONG
LONGBLOB LONGTEXT LOOP
LOW_PRIORITY MATCH MEDIUMBLOB
MEDIUMINT MEDIUMTEXT MIDDLEINT
MINUTE_MICROSECOND MINUTE_SECOND MOD
MODIFIES NATURAL NOT
NO_WRITE_TO_BINLOG NULL NUMERIC
ON OPTIMIZE OPTION
OPTIONALLY OR ORDER
OUT OUTER OUTFILE
PRECISION PRIMARY PROCEDURE
PURGE RAID0 RANGE
READ READS REAL
REFERENCES REGEXP RELEASE
RENAME REPEAT REPLACE
REQUIRE RESTRICT RETURN
REVOKE RIGHT RLIKE
SCHEMA SCHEMAS SECOND_MICROSECOND
SELECT SENSITIVE SEPARATOR
SET SHOW SMALLINT
SPATIAL SPECIFIC SQL
SQLEXCEPTION SQLSTATE SQLWARNING
SQL_BIG_RESULT SQL_CALC_FOUND_ROWS SQL_SMALL_RESULT
SSL STARTING STRAIGHT_JOIN
TABLE TERMINATED THEN
TINYBLOB TINYINT TINYTEXT
TO