拜托,有人可以帮我修改下面的mysql代码吗?
它不会影响我想要的行。 :/我是初学者。
DELIMITER $$
DROP PROCEDURE IF EXISTS category$$
CREATE PROCEDURE category()
BEGIN
DECLARE count INT DEFAULT 877;
DECLARE prd INT;
WHILE count < 1040 DO
select product_id into prd from xxx_hikashop_product
where (replace(product_name, 'Model ', '') = count);
insert into xxx_hikashop_product_category
(product_category_id, category_id, product_id, ordering)
VALUES
(1445+count, 33, prd, count);
SET count = count + 1;
END WHILE;
END$$
DELIMITER ;
PRINTED ERROR:
#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'select product_id from elody_hikashop_product where replace(product_alias,
'mode' at line 7
答案 0 :(得分:0)
我将假设product_alias字段的格式为&#34; Model 888&#34;并尝试提取数值,并将其与计数进行比较。您需要使用以下命令将结果字符串转换为数字:
select product_id into prd from xxx_hikashop_product
where (convert(replace(product_name, 'Model ', ''), UNSIGNED) = count);
答案 1 :(得分:0)
唯一的问题是我忘了打电话给你:D谢谢你
菲利普