my statement is select user_vip_card
. , flow_of_vipcard
. , if ((user_vip_card.max_times IS NULL OR user_vip_card.max_times= 0 OR user_vip_card.max_times=9999),-1, (user_vip_card.max_times-count (flow_of_vipcard.id)
AS remain_times
, `place`.`place` as `company_text` from `user_vip_card` left join `flow_of_vipcard` on `flow_of_vipcard`.`user_vip_card_id` = `user_vip_card`.`id` left join `place` on `place`.`ID` = `user_vip_card`.`place_id` where (`user_vip_card`.`start_date` is null or `user_vip_card`.`start_date` <= "2018-05-15") and (`user_vip_card`.`end_date` is null or `user_vip_card`.`end_date` >= "2018-05-15") and `user_vip_card`.`uid` = "1816" and `user_vip_card`.`status` = "1" order by `user_vip_card`.`created_at` asc;ifififcount