行匹配:1 更改:0 警告:0 Mysql 更新未发生
Rows matched: 1 Changed: 0 Warnings: 0 Mysql update not happening
我正在从 mysql 命令行更新 table.. 更新没有发生..
table说明如下:
mysql> describe userdailycalorie;
+-------------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+----------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| balanced_diet | bit(1) | YES | | NULL | |
| calories_consumed | double | YES | | NULL | |
| date | datetime | YES | | NULL | |
| user_id | int(11) | YES | MUL | NULL | |
+-------------------+----------+------+-----+---------+-------+
5 rows in set (0.13 sec)
对应的table内容如下:
mysql> select * from userdailycalorie;
+----+---------------+-------------------+---------------------+---------+
| id | balanced_diet | calories_consumed | date | user_id |
+----+---------------+-------------------+---------------------+---------+
| 16 | | 0 | 2018-02-02 00:00:00 | 3 |
+----+---------------+-------------------+---------------------+---------+
1 row in set (0.00 sec)
对应的Update语句如下:
mysql> update userdailycalorie set calories_consumed= 205.4 and balanced_diet =true WHERE user_id = 3;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
匹配的行数为 1,表示它选择了该行。更新未按更改发生:0..我不确定为什么,...任何人都可以帮我调试这个问题吗?
你可以试试下面的-
update userdailycalorie
set calories_consumed= 205.4, balanced_diet =1
WHERE user_id = 3;
如果要更新两个不能使用的字段 AND
,请用逗号分隔要更新的每个字段 ,
update userdailycalorie
set calories_consumed = 205.4
, balanced_diet = true
WHERE user_id = 3;
我正在从 mysql 命令行更新 table.. 更新没有发生..
table说明如下:
mysql> describe userdailycalorie;
+-------------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+----------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| balanced_diet | bit(1) | YES | | NULL | |
| calories_consumed | double | YES | | NULL | |
| date | datetime | YES | | NULL | |
| user_id | int(11) | YES | MUL | NULL | |
+-------------------+----------+------+-----+---------+-------+
5 rows in set (0.13 sec)
对应的table内容如下:
mysql> select * from userdailycalorie;
+----+---------------+-------------------+---------------------+---------+
| id | balanced_diet | calories_consumed | date | user_id |
+----+---------------+-------------------+---------------------+---------+
| 16 | | 0 | 2018-02-02 00:00:00 | 3 |
+----+---------------+-------------------+---------------------+---------+
1 row in set (0.00 sec)
对应的Update语句如下:
mysql> update userdailycalorie set calories_consumed= 205.4 and balanced_diet =true WHERE user_id = 3;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
匹配的行数为 1,表示它选择了该行。更新未按更改发生:0..我不确定为什么,...任何人都可以帮我调试这个问题吗?
你可以试试下面的-
update userdailycalorie
set calories_consumed= 205.4, balanced_diet =1
WHERE user_id = 3;
如果要更新两个不能使用的字段 AND
,请用逗号分隔要更新的每个字段 ,
update userdailycalorie
set calories_consumed = 205.4
, balanced_diet = true
WHERE user_id = 3;