select *, if(time() >= startData and time() <= endData, 1, if(time() < startData, 2, 3)) as o from actions where ?????? order by o
我觉得你这样子想要一条sql写完性能会死的很惨
StevenTong
2015-03-18 15:51:26 +08:00
select actions.*, if(current_timestamp > actions.startDate and current_timestamp < actions.endDate,1,0) as status, if(current_timestamp < actions.startDate,2,0) as status, if(current_timestamp > actions.endDate,3,0) as status from actions, actions_members where actions_members.m_id = 3 and actions_members.status = "ok" and actions.id = actions_members.t_id order by status asc;