UPDATE query is not working with LIMIT

2019-08-05 18:26发布

hi i am using an UPDATE query with limit 0,1 where i have to update the first row which matches the condition which i m giving in the query

mysql_query("UPDATE `product_option` SET `input_value`='$color_a',`input_price`='$color_price_a' WHERE `product_id`='$_REQUEST[pid]' and `input_type`='option' LIMIT 0,1"); 

in my sql table the $_request[pid] is repeating many times so on that rows in which $_request[pid] is matching, i want to update the first row on it but this query is not doing any thing the data is still same which i have added.

any suggestion will be appreciated

here is the image of the table

enter image description here

标签: php mysql limit
1条回答
forever°为你锁心
2楼-- · 2019-08-05 18:38

It should be LIMIT 1

LIMIT 0,1 means OFFSET 0 LIMIT 1, but UPDATE does not support offsets.

Even if it would work (which it doesn't) you still always have to supply an ORDER clause or it will be a random row.

查看更多
登录 后发表回答