在指定时间删除行/数据

编程入门 行业动态 更新时间:2024-10-28 21:21:42
本文介绍了在指定时间删除行/数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图根据当前日期创建一个删除行的查询。有效。但现在,我希望是否有可能在指定时间内删除数据。因此用户可以选择他/她希望何时删除数据。例如凌晨4点。我如何使用当前的代码执行此操作。请帮忙。

mysql_query( DELETE FROM`sec_codes` WHERE DATE(date)< CURDATE());

解决方案

HI 尝试SQL Server工作 创建Transact-SQL作业步骤 [ ^ ] 使用SQL Server Management Studio创建数据库备份作业 [ ^ ] 问候, GVPrabu

铜rTime()也是作为CurDate()的Smae函数;因此,如果CurDate()正在工作,那么CurTime()也应该工作。 试一试。

您好,通过以下代码,您可以根据需要更改条件。您可以将参数传递给您想要的日期时间删除记录。我已经注释删除查询的代码首先检查选择然后如果确定然后执行删除语句 声明@ date1 varchar(16) --set @ date1 =''2013-02-24 01:10'' set @ date1 = convert(varchar(10),getdate(),120)+''01:35 :00'' 选择*,转换(datetime,rct,111) - ,@ date1 from photo_test where convert(datetime ,rct,111)>转换(datetime,@ date1,111) - 从photo_test中删除convert(datetime,rct,111)>转换(日期时间,@ date1,111)

I was trying to make a query that would delete the rows according to the current date. it worked. but now, I wished if its possible to delete the data on a specified time. so the user can select when he/she wishes to delete the data. for example 4am. how do i do that with the current code I have. Please help.

mysql_query("DELETE FROM `sec_codes` WHERE DATE(date) < CURDATE()");

解决方案

HI Try SQL Server Jobs Create a Transact-SQL Job Step[^] Create a database backup job using SQL Server Management Studio[^] Regards, GVPrabu

CurTime() is also the Smae function as CurDate(); So if CurDate() is Working then CurTime() should also work. Try it.

Hi,Go through the following code you can change the condition as you want.You can pass the parameter for date time on which you want to delete the record. I have commented code for delete query first check with select then if it is ok then execute delete statement declare @date1 varchar(16) --set @date1=''2013-02-24 01:10'' set @date1=convert(varchar(10),getdate(),120)+'' 01:35:00'' select *,convert(datetime,rct,111) --,@date1 from photo_test where convert(datetime,rct,111) > convert(datetime,@date1,111) --Delete from photo_test where convert(datetime,rct,111) > convert(datetime,@date1,111)

更多推荐

在指定时间删除行/数据

本文发布于:2023-11-24 09:53:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624738.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时间   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!