我正在从 mysql 命令行更新表..更新没有发生..
表格说明如下:
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)
对应的表格内容如下:
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
Rows matched is 1 这表明它选择了行..更新没有发生变化:0..我不确定为什么,...任何人都可以帮我调试这个问题吗?
最佳答案
如果你想更新两个字段不能使用AND
,用逗号分隔每个要更新的字段,
update userdailycalorie
set calories_consumed = 205.4
, balanced_diet = true
WHERE user_id = 3;
关于mysql - 行匹配 : 1 Changed: 0 Warnings: 0 Mysql update not happening,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53910870/