【问题标题】:mysql query seems to be error.can i select the updated column with one querymysql 查询似乎是错误的。我可以用一个查询选择更新的列吗
【发布时间】:2014-10-17 06:01:53
【问题描述】:

您的 SQL 查询中似乎有错误。下面的 MySQL 服务器错误输出,如果有的话,也可以帮助您诊断问题。

错误:未封闭的报价@ 173 字符串:“

update voucher_nos 
set (select voucher_type as points from vouchers where id='1') = points+1 
where company_id = '24' 
      and finance_year='01/01/2014-01/01/2015';



update voucher_nos 
set (select voucher_type as points from vouchers where id='1') = points+1 
where company_id = '24' 
       and finance_year='01/01/2014-01/01/2015'";

1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在 '(selectvoucher_type 作为来自凭证的点数附近使用的正确语法 其中 id='1') = points+1 w' 在第 1 行

帮助将不胜感激

【问题讨论】:

    标签: mysql error-handling


    【解决方案1】:
    and finance_year='01/01/2014-01/01/2015'";
    

    这里最后有一个不必要的 ",这可能导致语法错误。

    --

    第二个问题是 SET 语句的第一部分应该是列名,而不是值(或返回值的查询)。但我不知道如何解决这个问题,除非你多解释一下你想要完成的事情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-16
      • 2013-04-26
      • 1970-01-01
      • 2010-12-25
      相关资源
      最近更新 更多