我正在从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
匹配的行数为1,表示它选择了行。。更新未按更改进行:0。。我不知道为什么,。。。有人能帮我调试这个问题吗?
2条答案
按热度按时间ukxgm1gy1#
如果你想更新两个字段不能使用
AND
,用coma分隔要更新的每个字段,
```update userdailycalorie
set calories_consumed = 205.4
, balanced_diet = true
WHERE user_id = 3;
snvhrwxg2#
你可以在下面试试-