SELECT ( CASE
WHEN 1944.0000 >= country_from_price
AND 1944.0000 <= country_to_price
THEN ((1944.0000 + ((1944.0000 * country_percentage)/100)))
ELSE 1944.0000
END
)
FROM `country_markup`
WHERE estatus = '1'
AND country_id REGEXP '[[:<:]]138[[:>:]]'
以上查询返回值按百分比增加,但如果条件未满,则返回 NULL。我想要的是如果查询返回 NULL 值而不是它应该返回 1944.0000 并且为此我尝试了下面的代码但没有成功
SELECT IF( (SELECT (CASE
WHEN 1944.0000 >= country_from_price
AND 1944.0000 <= country_to_price
THEN ((1944.0000 + ((1944.0000 * country_percentage)/100)))
ELSE 1944.0000
END
) as f1
FROM `country_markup`
WHERE estatus = '1'
AND country_id REGEXP '[[:<:]]223[[:>:]]') IS NOT NULL, f1 ,1944.0000) as final_price
提前致谢