sc delete mysql 1060_MySQL错误1060:栏名称重复ALTER TABLE

bd96500e110b49cbb3cd949968f18be7.png

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;

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;");

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.

解决方案

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值