'SELECT conversation_id, viewed_on,('max_unixtime().' - last_reply) AS newest_conversation FROM `Conversation_Participant` WHERE `user_id`='.$self->{user}->get('id').' ORDER BY newest_conversation DESC'
我需要在max_unixtime() - last_reply>时设置newest_conversation。 last_viewed ..
如何在查询中设置if语句?
答案 0 :(得分:2)
...CASE WHEN max_unixtime() - last_reply > last_viewed
THEN ('max_unixtime().' - last_reply)
ELSE NULL END AS newest_conversation...