MySQL语法错误:可能在IFNULL中

时间:2018-04-02 16:24:49

标签: mysql sql syntax

需要帮助。有以下MySQL(版本:5.7.21)suntax错误:

  

#1064 - 您的SQL语法出错;检查手册   对应于您的MySQL服务器版本,以便使用正确的语法   靠近' .model,ucp.list_price,ucp.sell_price,(ucp.list_price -   IFNULL((选择(CASE WH'第1行

用于以下查询:

SELECT n.nid, n.title,n.created ucp.model,
ucp.list_price,ucp.sell_price, (ucp.list_price - IFNULL((SELECT (CASE
WHEN role_price.price='' THEN ucp.sell_price ELSE role_price.price
END) AS price FROM uc_price_per_role_prices role_price WHERE
role_price.nid=n.nid AND role_price.rid IN (2,3,4)) , ucp.sell_price )
) AS profitability, height.field_product_package_height_value,
width.field_product_package_width_value,
length.field_product_package_length_value FROM node n JOIN uc_products
ucp ON n.nid=ucp.nid JOIN field_data_field_product_package_height
height ON n.nid=height.entity_id JOIN
field_data_field_product_package_width width ON n.nid=width.entity_id
JOIN field_data_field_product_package_length length ON
n.nid=length.entity_id WHERE n.status =1 AND n.nid NOT IN   (2298,2299,2300,2301,2302,2303,2304,2305,2307,2308,2309,2310,2311,2312,2313,2
314,13963,13964)
AND height.field_product_package_height_value !='' AND
width.field_product_package_width_value !='' AND
length.field_product_package_length_value !='' GROUP BY n.nid ORDER BY
n.created DESC LIMIT 20 OFFSET 0

1 个答案:

答案 0 :(得分:0)

看起来像一个额外的结束括号)

IFNULL((SELECT (CASE WHEN role_price.price='' THEN ucp.sell_price 
ELSE role_price.price END) AS price FROM uc_price_per_role_prices role_price
WHERE role_price.nid=n.nid AND role_price.rid 
IN (2,3,4), ucp.sell_price ) ) AS profitability