一个比较诡异的问题,为什么会报Duplicate column name 'type_name' 我有用a、b区分呀.顺便一提将其中的SELECT语句单独拿出来是不报错的.
UPDATE tdb_goods_types AS t1 INNER JOIN(SELECT a.type_id,a.type_name,b.type_name ,count(a.type_id) as count
FROM tdb_goods_types as a LEFT JOIN tdb_goods_types as b
ON a.type_id = b.parent_id GROUP BY a.type_id)AS t2
ON t1.type_id = t2.type_id
SET t1.child_count = t2.count;