You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行MySQL插入语句遇Error 1054错误,疑因数据类型问题求助

Fixing Error 1054: Unknown Column in Field List

The immediate cause of your error is **incorrect use of backticks () for string values** in your INSERT statement. In MySQL, backticks are reserved for escaping column or table names—not for literal data. When you wrapped your userIDandreferenceName` values in backticks, MySQL interpreted them as column names instead of the string values you intended to insert, hence the "unknown column" message.

Step 1: Correct the Quote Usage

Replace the backticks around your values with single quotes ('). Here's the corrected INSERT statement:

INSERT INTO `new_table` (`userID`, `referenceName`, `id`) 
VALUES ('213526487623121521', '@RandomUser#5524', 1);

Step 2: Fix the id Primary Key Issue

Your table defines id as INT NOT NULL PRIMARY KEY, which means you must provide a value for it in every insert (unless you configure it to auto-increment). If you don't want to manually specify id each time, modify your table to make id auto-incrementing:

ALTER TABLE `new_table` MODIFY COLUMN `id` INT NOT NULL AUTO_INCREMENT;

With this change, you can omit id from your INSERT statement entirely:

INSERT INTO `new_table` (`userID`, `referenceName`) 
VALUES ('213526487623121521', '@RandomUser#5524');

Quick Recap

  • Use single quotes (') for string literals in MySQL.
  • Backticks (`) should only be used for column/table names that have special characters or are reserved keywords.
  • Your userID value (213526487623121521) fits within the varchar(20) limit, so data type mismatch isn't the issue here—though it's good you checked that angle!

内容的提问来源于stack exchange,提问作者CTLYST

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:27:05