这是一个演示查询,请注意,它非常简单,仅在base_price为0的地方获取,并且仍然选择条件3:
SELECT
CASE course_enrollment_settings.base_price
WHEN course_enrollment_settings.base_price = 0 THEN 1
WHEN course_enrollment_settings.base_price<101 THEN 2
WHEN course_enrollment_settings.base_price>100 AND
course_enrollment_settings.base_price<201 THEN 3
ELSE 6
END AS 'calc_base_price',
course_enrollment_settings.base_price
FROM
course_enrollment_settings
WHERE course_enrollment_settings.base_price = 0
base_price
是 decimal(8,0)
在数据库上运行此命令时,我得到:
3 0
3 0
3 0
3 0
3 0