"check the manual that corresponds to your MySQL server version for the right syntax to use“解决

发布于:2021-12-08 21:19:32

今晚做项目的时候,遇到了这个问题,很是纳闷。


由于项目的sql代码是利用mybatis的generator自动生成的,没有手写mysql语句,项目却报sql语句错误。于是调试程序还是觉得sql没有错误,但是偏偏就是报错。


百度后找到发现原来是mysql遗留的关键字在作祟。我的表名join,恰巧就是其中的一员~


解决办法:修改表名,join->joins,问题解决。


总结:无论是建表、字段、变量还是工程名最好不要用一些关键词作为命名,以免带来不必要的麻烦。


附(MySQL5.7关键字和保留字):



Table?1 Keywords and Reserved Words in MySQL 5.7



ACCESSIBLE?(R) ACCOUNT[a] ACTION
ADD?(R) AFTER AGAINST
AGGREGATE ALGORITHM ALL?(R)
ALTER?(R) ALWAYS[b] ANALYSE
ANALYZE?(R) AND?(R) ANY
AS?(R) ASC?(R) ASCII
ASENSITIVE?(R) AT AUTOEXTEND_SIZE
AUTO_INCREMENT AVG AVG_ROW_LENGTH
BACKUP BEFORE?(R) BEGIN
BETWEEN?(R) BIGINT?(R) BINARY?(R)
BINLOG BIT BLOB?(R)
BLOCK BOOL BOOLEAN
BOTH?(R) BTREE BY?(R)
BYTE CACHE CALL?(R)
CASCADE?(R) CASCADED CASE?(R)
CATALOG_NAME CHAIN CHANGE?(R)
CHANGED CHANNEL[c] CHAR?(R)
CHARACTER?(R) CHARSET CHECK?(R)
CHECKSUM CIPHER CLASS_ORIGIN
CLIENT CLOSE COALESCE
CODE COLLATE?(R) COLLATION
COLUMN?(R) COLUMNS COLUMN_FORMAT
COLUMN_NAME COMMENT COMMIT
COMMITTED COMPACT COMPLETION
COMPRESSED COMPRESSION[d] CONCURRENT
CONDITION?(R) CONNECTION CONSISTENT
CONSTRAINT?(R) CONSTRAINT_CATALOG CONSTRAINT_NAME
CONSTRAINT_SCHEMA CONTAINS CONTEXT
CONTINUE?(R) CONVERT?(R) CPU
CREATE?(R) CROSS?(R) CUBE
CURRENT CURRENT_DATE?(R) CURRENT_TIME?(R)
CURRENT_TIMESTAMP?(R) CURRENT_USER?(R) CURSOR?(R)
CURSOR_NAME DATA DATABASE?(R)
DATABASES?(R) DATAFILE DATE
DATETIME DAY DAY_HOUR?(R)
DAY_MICROSECOND?(R) DAY_MINUTE?(R) DAY_SECOND?(R)
DEALLOCATE DEC?(R) DECIMAL?(R)
DECLARE?(R) DEFAULT?(R) DEFAULT_AUTH
DEFINER DELAYED?(R) DELAY_KEY_WRITE
DELETE?(R) DESC?(R) DESCRIBE?(R)
DES_KEY_FILE DETERMINISTIC?(R) DIAGNOSTICS
DIRECTORY DISABLE DISCARD
DISK DISTINCT?(R) DISTINCTROW?(R)
DIV?(R) DO DOUBLE?(R)
DROP?(R) DUAL?(R) DUMPFILE
DUPLICATE DYNAMIC EACH?(R)
ELSE?(R) ELSEIF?(R) ENABLE
ENCLOSED?(R) ENCRYPTION[e] END
ENDS ENGINE ENGINES
ENUM ERROR ERRORS
ESCAPE ESCAPED?(R) EVENT
EVENTS EVERY EXCHANGE
EXECUTE EXISTS?(R) EXIT?(R)
EXPANSION EXPIRE EXPLAIN?(R)
EXPORT EXTENDED EXTENT_SIZE
FALSE?(R) FAST FAULTS
FETCH?(R) FIELDS FILE
FILE_BLOCK_SIZE[f] FILTER[g] FIRST
FIXED FLOAT?(R) FLOAT4?(R)
FLOAT8?(R) FLUSH FOLLOWS[h]
FOR?(R) FORCE?(R) FOREIGN?(R)
FORMAT FOUND FROM?(R)
FULL FULLTEXT?(R) FUNCTION
GENERAL GENERATED[i]?(R) GEOMETRY
GEOMETRYCOLLECTION GET?(R) GET_FORMAT
GLOBAL GRANT?(R) GRANTS
GROUP?(R) GROUP_REPLICATION[j] HANDLER
HASH HAVING?(R) HELP
HIGH_PRIORITY?(R) HOST HOSTS
HOUR HOUR_MICROSECOND?(R) HOUR_MINUTE?(R)
HOUR_SECOND?(R) IDENTIFIED IF?(R)
IGNORE?(R) IGNORE_SERVER_IDS IMPORT
IN?(R) INDEX?(R) INDEXES
INFILE?(R) INITIAL_SIZE INNER?(R)
INOUT?(R) INSENSITIVE?(R) INSERT?(R)
INSERT_METHOD INSTALL INSTANCE[k]
INT?(R) INT1?(R) INT2?(R)
INT3?(R) INT4?(R) INT8?(R)
INTEGER?(R) INTERVAL?(R) INTO?(R)
INVOKER IO IO_AFTER_GTIDS?(R)
IO_BEFORE_GTIDS?(R) IO_THREAD IPC
IS?(R) ISOLATION ISSUER
ITERATE?(R) JOIN?(R) JSON[l]
KEY?(R) KEYS?(R) KEY_BLOCK_SIZE
KILL?(R) LANGUAGE LAST
LEADING?(R) LEAVE?(R) LEAVES
LEFT?(R) LESS LEVEL
LIKE?(R) LIMIT?(R) LINEAR?(R)
LINES?(R) LINESTRING LIST
LOAD?(R) LOCAL LOCALTIME?(R)
LOCALTIMESTAMP?(R) LOCK?(R) LOCKS
LOGFILE LOGS LONG?(R)
LONGBLOB?(R) LONGTEXT?(R) LOOP?(R)
LOW_PRIORITY?(R) MASTER MASTER_AUTO_POSITION
MASTER_BIND?(R) MASTER_CONNECT_RETRY MASTER_DELAY
MASTER_HEARTBEAT_PERIOD MASTER_HOST MASTER_LOG_FILE
MASTER_LOG_POS MASTER_PASSWORD MASTER_PORT
MASTER_RETRY_COUNT MASTER_SERVER_ID MASTER_SSL
MASTER_SSL_CA MASTER_SSL_CAPATH MASTER_SSL_CERT
MASTER_SSL_CIPHER MASTER_SSL_CRL MASTER_SSL_CRLPATH
MASTER_SSL_KEY MASTER_SSL_VERIFY_SERVER_CERT?(R) MASTER_TLS_VERSION[m]
MASTER_USER MATCH?(R) MAXVALUE?(R)
MAX_CONNECTIONS_PER_HOUR MAX_QUERIES_PER_HOUR MAX_ROWS
MAX_SIZE MAX_STATEMENT_TIME[n] MAX_UPDATES_PER_HOUR
MAX_USER_CONNECTIONS MEDIUM MEDIUMBLOB?(R)
MEDIUMINT?(R) MEDIUMTEXT?(R) MEMORY
MERGE MESSAGE_TEXT MICROSECOND
MIDDLEINT?(R) MIGRATE

相关推荐

最新更新

猜你喜欢