这是处理MySQL中真实条件的多个case语句的正确方法吗?
SELECT
CASE WHEN place='India' THEN `Order` END AS `Order`
CASE WHEN place='India' THEN `Amount` END AS `Amount`
或者,如果条件为真,是否有更好的方法来获取订单和金额?
答案 0 :(得分:1)
试试这个:
SELECT
CASE WHEN place='India' THEN 'Order' END AS 'Order',
CASE WHEN place='India' THEN 'Amount' END AS 'Amount'
from *table*
Case语句只能返回一个值;你必须执行两个单独的语句才能获得这两个值。