我有一个名为ps_cart_product
的表,结构如下:
>desc ps_cart_product;
+----------------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+------------------+------+-----+---------+-------+
| id_cart | int(10) unsigned | NO | MUL | NULL | |
| id_product | int(10) unsigned | NO | | NULL | |
| id_address_delivery | int(10) unsigned | YES | | 0 | |
| id_shop | int(10) unsigned | NO | | 1 | |
| id_product_attribute | int(10) unsigned | YES | MUL | NULL | |
| quantity | int(10) unsigned | NO | | 0 | |
| date_add | datetime | NO | | NULL | |
+----------------------+------------------+------+-----+---------+-------+
此表有几行。我想用id_cart=625 AND id_product=63
更新第二行。
如果我查询:
> select * from ps_cart_product where id_cart=625 and id_product=63;
+---------+------------+---------------------+---------+----------------------+----------+---------------------+
| id_cart | id_product | id_address_delivery | id_shop | id_product_attribute | quantity | date_add |
+---------+------------+---------------------+---------+----------------------+----------+---------------------+
| 625 | 63 | 0 | 1 | 279 | 2 | 2015-05-18 10:29:23 |
| 625 | 63 | 0 | 1 | 275 | 1 | 2015-05-18 10:28:55 |
+---------+------------+---------------------+---------+----------------------+----------+---------------------+
2 rows in set (0.01 sec)
我想执行一个SQL UPDATE语句,如:
UPDATE ps_cart_product
SET id_product_attribute = 280
WHERE id_cart = 625
AND id_product = 63
AND XXXXXXXX
我不知道在XXXXXXXX
写什么来只更新第二行。我无法使用id_product_attribute
,quantity
或date_add
的语句来过滤UPDATE
语句,因为我无法控制其价值。
答案 0 :(得分:0)
如果您可以引入自动增量id
字段,那么我希望这可以解决您的问题。