请帮助我的mysql脚本,我赶上了一个错误。我有一个表(tbl\u products),其中包含p\u id和prod\u skuid字段,我想将所有重复的prod\u skuid更新到我的tbl\u products中。
以下是我的mysql脚本:
UPDATE tbl_product t1 SET t1.prod_skuid = t.prod_skuid
(
SELECT p_id, prod_skuid from
(SELECT p_id,if(@row = prod_skuid, @count, @count := 1),
CONCAT(prod_skuid, '', @count) as prod_skuid,
@row := prod_skuid,
@count := @count + 1
from tbl_product JOIN (SELECT @count := 0, @row := "") as t
WHERE prod_skuid IN(SELECT prod_skuid from tbl_product group by prod_skuid having count(prod_skuid) > 1)
) as final
) as t
WHERE t1.p_id = t.p_id
我只使用嵌套的select而不使用update scrpit来显示和更改prod\u skuid,但是当我放入update脚本时,它表示我的代码有错误:
SELECT p_id, prod_skuid from
(SELECT p_id,if(@row = prod_skuid, @count, @count := 1),
CONCAT(prod_skuid, '', @count) as prod_skuid,
@row := prod_skuid,
@count := @count + 1
from tbl_product JOIN (SELECT @count := 0, @row := "") as t
WHERE prod_skuid IN(SELECT prod_skuid from tbl_product group by prod_skuid having count(prod_skuid) > 1)
) as final
错误:mysql错误消息
1条答案
按热度按时间bjg7j2ky1#
不管怎样,我现在得到了答案。我做了这么多测试,现在是: