MySQL #1054 - 未知列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13055680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 15:16:20  来源:igfitidea点击:

#1054 - Unknown column

mysqlsqlvarcharsqldatatypesmysql-error-1054

提问by Zain Ali

I am using MySQL 5.5 and phpmyadmin 3.5.2 (provided by http://www.freewebhostingarea.com)

我正在使用 MySQL 5.5 和 phpmyadmin 3.5.2(由http://www.freewebhostingarea.com提供)

My sql query is:

我的 sql 查询是:

INSERT INTO `example`(`id`, `name`, `password`) VALUES (1,we,5)

where id is int type, name and password are varchar.

其中 id 是 int 类型,名称和密码是varchar.

but when ever inserting any value other than integer in name and age,it displays #1054 error, i.e

但是当在 name 和 age 中插入除整数以外的任何值时,它会显示 #1054 错误,即

#1054 - Unknown column 'we' in 'field list'

回答by Blaise Swanwick

You must surround any strings with quotes.

您必须用引号将任何字符串括起来。

INSERT INTO `example`(`id`, `name`, `password`) 
VALUES               (1,'User Name','Password123')

回答by Robert

You have to add ''for weand probably for password:

您必须添加''forwe并且可能是 for password

INSERT INTO `example`(`id`, `name`, `password`) VALUES (1,'we','5')

because both values are char type.

因为这两个值都是 char 类型。