MySQL: Delete rows that contain a specific parameter and are older then a day [closed]

萝らか妹 提交于 2020-01-30 13:28:08

问题


I'm creating a login system for my website, with mysql. It works on a subscription based system. How would I remove all rows with the parameter "premium" equal to "1 DAY", if it's older then a day. I'm trying to run a command like this, in a cron job, that runs once a day. I would duplicate this for rows that have the parameter "premium" = "1 WEEK", etc.

Thanks,


回答1:


It would be something like:

delete t from loginsystem t
    where premium = '1 DAY' and created_at < now() - interval 1 day;


来源:https://stackoverflow.com/questions/49086792/mysql-delete-rows-that-contain-a-specific-parameter-and-are-older-then-a-day

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!