mysql - mysql 在同一张表的更新中出现语法错误
问题描述
显示的错误
1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在附近使用的正确语法
我认为语法错误
update invoice AS t1,
(select sum(total_cost) from invoice where billno='X-0125' and item='11') AS t2
set t1.total_cost=(t1.total_cost/(t2.sum(total_cost))*100
WHERE t1.billno='X-0125' and t1.item='11'
解决方案
例如,在“100”之后缺少一个括号(取决于您想要什么)但缺少一个:
update
invoice AS t1,
(
select
sum(total_cost)
from
invoice
where
billno = 'X-0125'
and item = '11'
) AS t2
set
t1.total_cost =(t1.total_cost /(t2.sum(total_cost)) * 100)
WHERE
t1.billno = 'X-0125'
and t1.item = '11'
推荐阅读
- node.js - 在浏览器中查看而非下载 Google Cloud Storage 文件
- python - 按位置获取大量推文
- json - 从 Oracle 存储过程生成 JSON
- ruby-on-rails - Rails 与自身的关联不起作用
- qt - 如何使用 QMessageBox 显示纯文本?
- python - 遍历进程列表以检查 PID 是否与 Python 子进程一起存在
- c++ - 正则表达式在 23 个字符处停止工作,但前提是我传入字符串文字
- windows - 在两个不同进程之间共享文件句柄
- arrays - 在多个文本文件中搜索字符串并通过将其附加到 summary_[date].log 来复制行
- asp.net - IIS 上的 ASp.Net MVC 站点,仅 CSS 文件出现 500 错误