时间:2010-07-12 07:12:47

标签: sql mysql

我想要一个mysql中if子句的简单示例。我不想考虑其他情况,只有条款

1 个答案:

答案 0 :(得分:3)

例如:

SELECT *,
       if (`date_last` IS NULL,prev_date,last_date) as date 
FROM `table_name` 
WHERE `id` = 2 
ORDER BY `date` DESC