0

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

 (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 used 购买价格 * 1.37,如果是则将价格设置为 follette used 购买价格 * 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

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

4

1 回答 1

2

我认为你有一个错误的')'

你需要的是

(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,
于 2012-08-14T13:35:00.127 回答