MySQL错误1060:重复的列名ALTER TABLE [英] MySQL Error 1060: Duplicate column name ALTER TABLE

查看:828
本文介绍了MySQL错误1060:重复的列名ALTER TABLE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我未创建的代码中的错误,我在查询中遇到了一些问题.

I am having some problems with a query because of errors in the code that I did not create.

$query = $this->db->query("ALTER TABLE `" . DB_PREFIX . "customer` ADD `customer_type` TINYINT(1) NOT NULL; 

我不是编码员,但到目前为止(我认为)已修复了该错误.通过与不会引发错误的其他查询进行比较,并在stackoverflow上阅读了很多类似的文章,我添加了缺失的引号,括号和分号.没有更多的错误,但是不确定这是否是正确的方法吗?我结束了:

I'm not a coder, but have so far fixed (I think) the error. By comparing with other queries that don't throw errors and reading quite a few similar posts on stackoverflow, I added a missing quote, a parenthese, and semi-colon. No more error, but not sure if this is even the correct way of doing it? I ended up with this:

$query = $this->db->query("ALTER TABLE `" . DB_PREFIX . "customer` ADD `customer_type` TINYINT(1) NOT NULL;");

但是,现在,我收到重复列错误1060重复列名".因此,我做了同样的事情,从中搜索了一下,搜索stackoverflow并找到了一些使用别名和一些额外代码行的示例,这些代码超出了我的脑海.这段代码位于.php文件中,有人会牵着我走吗?您可以认为这是您当天的好事!谢谢您的宝贵时间.

But now, I get a duplicate column error 1060 "duplicate column name". So I did the same thing, googled the heck out of it, search stackoverflow and found some examples using aliases and a bunch of extra lines of code which is way above my head. This code lives in side a .php file, would someone kindly hold my hand through this? You could consider it your good deed for the day! Thanks for your time.

推荐答案

这意味着该列已存在于您的表中,很可能是前程序员想要添加该列而忘记删除查询aftewrads.

It means that the column already exists in your table, most likely the former programmer wanted to add the column and forgot to delete the query aftewrads.

这篇关于MySQL错误1060:重复的列名ALTER TABLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆