mysql - 使用 TINYINT 变量的更新语句会在 mySQL 中引发错误

标签 mysql sql syntax sql-update tinyint

我尝试在 mySQL 中使用简单的更新查询,但找不到答案。

我尝试做的,因为“农林业”是一个tinyint变量:

UPDATE Projects
SET agroforestry = FALSE,
WHERE project_id=2;

以下查询在同一数据集上完美运行:

UPDATE Projects
SET contact_person_mail='<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6b1d0205080e051f2b070a0445090e" rel="noreferrer noopener nofollow">[email protected]</a>',
    geographical_scope='national',
    country='Belgium',
    budget=4500000,
    currency='EUR'
WHERE project_id=2;

...但是当我尝试更新tinyint( bool )变量时出现语法错误。我已经尝试过这一切:

agroforestry = FALSE
agroforestry = False
agroforestry = false
agroforestry = 'FALSE'
agroforestry = 'False'
agroforestry = 'false'
agroforestry = 0
agroforestry = 1
agroforestry = TRUE
...

没有任何作用!我做错了什么?

最佳答案

在您的示例中,您有

UPDATE Projects
SET agroforestry = FALSE,
WHERE project_id=2;

去掉 FALSE 后面的逗号。它不属于那里。 SET 子句中的逗号仅存在于分隔列中。要修改的最后一列(在本例中是唯一的列)后面不能跟逗号。

关于mysql - 使用 TINYINT 变量的更新语句会在 mySQL 中引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34457374/

相关文章:

php - 从 SQL 循环遍历(并显示)多个表行

c# - Dapper 多映射 API splitOn 参数错误 - 我没有使用 MultiMapping

php - 单击链接运行 sql

javascript - 奇怪的 javascript 函数定义语法的文档? () => {}

c - 返回函数指针类型

php - 复制结构未知的 MySQL 行

mysql - 如何将总和转换为时间 - mysql

php - audio.js 音频播放器不适用于 angularjs ng-src

Mysql 跨表多个唯一键

javascript - `class Popup extends DivOverlay<LeafletElement, Props>` 语法在 JavaScript 中意味着什么?