标签:and 方案 子查询 mysql数据库 level index eai info set
1.查看删除数据库表的唯一约束
SHOW INDEX FROM tbl_name (唯一约束也是索引) ALTER TABLE tbl_name DROP INDEX index_name
将子查询作为一张表放在前面
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
标签:and 方案 子查询 mysql数据库 level index eai info set
原文地址:https://www.cnblogs.com/zarawu/p/10419845.html