MySQL:删除包含特定参数且早于一天的行 [英] MySQL: Delete rows that contain a specific parameter and are older then a day

查看:51
本文介绍了MySQL:删除包含特定参数且早于一天的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mysql为我的网站创建一个登录系统.它适用于基于订阅的系统.如果参数"premium"大于"1 DAY",那么该如何删除呢?我试图在cron作业中运行这样的命令,该命令每天运行一次.我将对具有参数"premium" ="1 WEEK"等的行重复此操作.

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.

谢谢

推荐答案

它类似于:

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

这篇关于MySQL:删除包含特定参数且早于一天的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆