1.查看删除数据库表的唯一约束
SHOW INDEX FROM tbl_name (唯一约束也是索引) ALTER TABLE tbl_name DROP INDEX index_name
2.update where中不能使用子查询,解决方案如下:
将子查询作为一张表放在前面
UPDATE `areainfo` a, ( SELECT code FROM `areainfo` where level = 1 ) b SET a.`level` =2 WHERE a.`parent_code` = b.code UPDATE `areainfo` a, ( SELECT code, name FROM `areainfo` where level = 1 ) b SET a.`fullName` =concat(b.name,‘,‘,a.name) WHERE a.`parentCode` = b.code and a.level = 2 UPDATE `areainfo` a, ( SELECT code, name,parentCode FROM `areainfo` where level = 2 ) b , ( SELECT code, name FROM `areainfo` where level = 1 ) c SET a.`fullName` =concat(c.name,‘,‘,b.name,‘,‘,a.name) WHERE a.`parentCode` = b.code and b.`parentCode` = c.code and a.level = 3
原文地址:https://www.cnblogs.com/zarawu/p/10419845.html
时间: 2024-10-21 19:15:11