gpt4 book ai didi

使用if条件时mysql查询错误

转载 作者:太空宇宙 更新时间:2023-11-03 12:30:15 24 4
gpt4 key购买 nike

 SELECT tu.begin_date, tm.MAGAZINE_ID,`MAGAZINE_NAME`, CASE WHEN ts.no_of_issues IS NULL THEN 1 ELSE ts.no_of_issues END AS Subscription_Type, 
CASE WHEN
IF(tu.customer_currency = 'USD', 54 * tu.customer_currency)
ELSE IF(tu.customer_currency = 'CAD', 1.0250 * tu.customer_currency)
END AS sale_price_inr,
tu.developer_proceeds as orginal_rate, tu.customer_currency as orginal_currency
FROM `tbl_itunes_report` tu
LEFT JOIN tbl_magazine_subscription ts ON ts.subscription_key = tu.sku_key
LEFT JOIN tbl_magazine_issue ti ON ti.PurchaseKey = tu.sku_key AND ti.OS_SELECT = 0
LEFT JOIN tbl_magazine tm ON tm.magazine_id = ts.magazine_id
OR tm.magazine_id = ti.magazine_id
WHERE `product_type_identifier` LIKE 'IA%'
AND
(
ts.subscription_key IS NOT NULL
OR ti.PurchaseKey IS NOT NULL
)
AND tu.begin_date >= '2012-04-01' AND tu.begin_date <= '2013-04-01'

这是我的查询。但是我执行了这个查询我得到了一个错误

 #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 ') ELSE IF(tu.customer_currency = 'CAD', 1.0250 * tu.customer_currency) END A' at line 3

有知道的请帮帮我。我是新手

提前致谢

最佳答案

改变

 ...
CASE WHEN
IF(tu.customer_currency = 'USD', 54 * tu.customer_currency)
ELSE IF(tu.customer_currency = 'CAD', 1.0250 * tu.customer_currency)
END AS sale_price_inr
...

...
CASE WHEN tu.customer_currency = 'USD' THEN 54 * tu.customer_currency
WHEN tu.customer_currency = 'CAD' THEN 1.0250 * tu.customer_currency
END AS sale_price_inr
...

关于使用if条件时mysql查询错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15788790/

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