由于某些原因,似乎没有更新行。知道为什么会这样吗?
UPDATE hts SET assigned='1' AND Owner='ms' WHERE hid='217477'
Query OK, 0 rows affected (0.16 sec)
Rows matched: 1 Changed: 0 Warnings: 0
select assigned, Owner from hts where hid='217477';
+----------+-------+
| assigned | Owner |
+----------+-------+
| NULL | NULL |
+----------+-------+
从hts显示列
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| hid | varchar(25) | YES | UNI | NULL | |
| assigned | int(11) | NO | | 0 | |
| Owner | varchar(10) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
答案 0 :(得分:3)
你可以尝试两件事......
首先尝试从SET中删除AND ..通常你用逗号来做..
UPDATE hts SET assigned=1, Owner='ms' WHERE hid='217477'
第二次尝试从hid
删除引号,如果它是INT而不是VARCHAR
UPDATE hts SET assigned=1, Owner='ms' WHERE hid=217477
不确定为什么要将整数存储为字符串.. 如果有疑问,您应该始终按照预期的数据类型存储数据。
建议:如果数据类型为varchar,则更改数据类型。您的更新将如下所示。
UPDATE hts SET assigned=1, Owner='ms' WHERE hid=217477
已分配应为整数以及隐藏