views:

56

answers:

1
+1  Q: 

if clause in mysql

i want a simple example of if clause in mysql. i don't want to consider else case,only if clause

+1  A: 

ex:

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