来自datetime字段的布尔值

时间:2011-01-03 18:52:42

标签: mysql

我需要一个布尔值(is_published),它指示日期时间字段published是否已设置或为空。

工作示例:

SELECT published, published IS NOT NULL as is_published  FROM `table`

1 个答案:

答案 0 :(得分:3)

SELECT (CASE publishedDateTime IS NULL THEN 0 ELSE 1 END CASE) AS is_published