我有下一个代码:
SET @rownum=0;
UPDATE product_images AS t, (SELECT @rownum:=@rownum+1 rownum, id, rel
FROM product_images WHERE product_id='227') AS r
SET t.rel = r.rownum
WHERE t.id = r.id
这在 phpmyadmin 中运行良好
但是...下一个代码(女巫实际上是一样的)但是放在php代码中
mysql_query ("
SET @rownum=0;
UPDATE product_images AS t,
(SELECT @rownum:=@rownum+1 rownum, product_images.*
FROM product_images WHERE product_id='$pid') AS r
SET t.rel = r.rownum WHERE t.id = r.id ") or die(mysql_error());
给我错误:"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 'UPDATE product_images AS t, (SELECT @rownum:=@rownum+1 rownum, product_images.* ' at line 1"
请帮忙。谢谢你。