gpt4 book ai didi

Mysql使用if语句出现语法错误1064

转载 作者:行者123 更新时间:2023-11-29 08:48:23 25 4
gpt4 key购买 nike

我正在尝试运行以下查询:

 (IF(book.book_type_id = "1", IF(inventory.cost < (follette_title.usedbuyingprice *1.37), follette_title.usedbuyingprice*1.37)), inventory.cost) AS Cost,

它试图查看书籍类型是否为 1,然后检查成本是否小于 follette 使用的购买价格 * 1.37,如果是则将价格设置为 follette 使用的购买价格 * 1.37,如果不是则设置价格成本就是成本。我不断收到此错误:

[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')), inventory.cost) AS Cost,
(concat(IFNULL(buyer_type.buyer_type, ""),IFNUL' at line 11

我不知道为什么。该手册没有给出明确的原因,而且我在这之前有很多类似的行,其中没有错误。谁能指出我正确的方向吗?

最佳答案

我认为你放错了地方')'

你需要的是

(IF(book_type.book_type_id = "1", IF(inventory.cost < follette_title.usedbuying_price *1.37, follette_title.usedbuying_price*1.37, ""), inventory.cost)) AS Cost

而不是

(IF(book.book_type_id = "1", IF(inventory.cost < (follette_title.usedbuyingprice *1.37), follette_title.usedbuyingprice*1.37)), inventory.cost) AS Cost,

关于Mysql使用if语句出现语法错误1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11953345/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com