简体   繁体   English

在MySQL中删除ID字段

[英]Delete ID field in MySQL

I am new to MySQL databases and I have just imported my Access database into MySQL. 我是MySQL数据库的新手,我刚刚将Access数据库导入到MySQL中。 When I did so, my primary key (ID) filed for one particular table is a bit messed up. 当我这样做时,我为一个特定表提交的主键(ID)有点混乱。

I would like all primary keys to be a number, but there is on that is showing up as a the height of a person. 我希望所有主键都是数字,但是上面显示的是一个人的身高。 This is not present in the Access database. 这在Access数据库中不存在。

I would add a picture but I cannot because I do not have the reputation yet... There is a 5' 7" in the ID place of an actual ID. When I attempt to delete this entry using the command 我会添加一张图片,但是我不能添加图片,因为我还没有声誉。实际ID的ID位置有5'7“。当我尝试使用以下命令删除此条目时

DELETE FROM actor_demographics WHERE ID=5' 7";

I am not able to delete the ID key. 我无法删除ID密钥。 Any ideas? 有任何想法吗?

DELETE FROM actor_demographics WHERE ID=5' 7";

MySQL不正确,应该是

DELETE FROM actor_demographics WHERE ID="5' 7\"";

It seems likely your ID column has a stringlike, not numberlike, data type. 您的ID列似乎有一个字符串型而非数字型数据类型。

Try using a string literal in your DELETE statement, thus 尝试在DELETE语句中使用字符串文字,因此

 DELETE FROM actor_demographics WHERE ID='5'' 7"';

Because you need a ' character in your string constant, double it to escape it. 由于在字符串常量中需要一个'字符,因此请将其加倍以进行转义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM