使用Mysql db的日期字段的case语句

时间:2016-03-14 07:28:05

标签: mysql sql

我试图做一个CASE声明。要求是,如果Date字段为NULL,则将其显示为“Pending”,或者显示db中的日期。

我已尝试过以下案例陈述,但存在一些问题。

CASE po_amend_received_date IS NULL WHEN 1 THEN 'Pending'  
ELSE po_amend_received_date END AS `po_amend_received_date`

我在这里犯了什么错误吗?

1 个答案:

答案 0 :(得分:0)

CASE WHEN po_amend_received_date IS NULL THEN 'Pending'  
else  po_amend_received_date 
end as `po_amend_received_date`