首页 \ 问答 \ phpMyAdmin事件错误#1542间隔太大(phpMyAdmin event error #1542 interval too big)

phpMyAdmin事件错误#1542间隔太大(phpMyAdmin event error #1542 interval too big)

我有一个MySQL事件删除超过1个月的任何行。 我现在想要更改它,以便删除超过6个月的行(它会清除游戏中发送的消息的数据库)。

我的(编辑过的)MySQL事件是:

DELETE FROM messages WHERE date < (NOW() - INTERVAL 6 MONTH)

我得到的错误是:

The following query has failed: "CREATE DEFINER=`admin`@`localhost` EVENT `delete msgs` ON SCHEDULE EVERY 0 DAY_HOUR STARTS '2013-07-19 18:00:00' ON COMPLETION PRESERVE ENABLE DO DELETE FROM messages WHERE date &lt; (NOW() - INTERVAL 6 MONTH)"
MySQL said: #1542 - INTERVAL is either not positive or too big

事件运行正常,但我甚至无法像现在这样保存它。 如果我打开事件并立即保存,我会得到同样的错误。


I have an MySQL event that deletes any rows older than 1 month. I now want to change that so it deletes rows older than 6 months (it cleans up a database for messages sent in a game).

My (edited) MySQL event is:

DELETE FROM messages WHERE date < (NOW() - INTERVAL 6 MONTH)

The error I get is:

The following query has failed: "CREATE DEFINER=`admin`@`localhost` EVENT `delete msgs` ON SCHEDULE EVERY 0 DAY_HOUR STARTS '2013-07-19 18:00:00' ON COMPLETION PRESERVE ENABLE DO DELETE FROM messages WHERE date &lt; (NOW() - INTERVAL 6 MONTH)"
MySQL said: #1542 - INTERVAL is either not positive or too big

The event functions fine but I can't even save it as it is now. If I open the event and immediately save I get the same error.


原文:https://stackoverflow.com/questions/22746314
更新时间:2023-03-10 11:03

最满意答案

假设a1; a2; a3在单元格A1中 ,请尝试使用此小宏将结果放在B列中:

Sub ReArrange()
    Dim N As Long, i As Long, BigString As String
    N = Cells(Rows.Count, 1).End(xlUp).Row
    BigString = Range("A1").Value
    For i = 2 To N
        BigString = BigString & ";" & Cells(i, 1).Value
    Next i
    i = 1
    ary = Split(BigString, ";")
    For Each a In ary
        Cells(i, 2).Value = a
        i = i + 1
    Next a
End Sub

编辑#1

根据您对额外列的需求,此宏会询问初始值并将结果放在A列和B列中:

Sub ReArrangeII()
    Dim N As Long, i As Long, BigString As String
    Dim M As Long, j As Long
    N = Cells(Rows.Count, 1).End(xlUp).Row
    M = Application.InputBox(Prompt:="enter initial value", Type:=1)
    j = 1
    For i = 1 To N
        BigString = Cells(i, 1).Value
        ary = Split(BigString, ";")
        u = UBound(ary) + 1
        For Each a In ary
            Cells(j, 2).Value = M
            Cells(j, 3).Value = a
            j = j + 1
        Next a
        M = M + 1
    Next i
End Sub

Assuming a1;a2;a3 is in cell A1 , try this small macro to place the results in column B :

Sub ReArrange()
    Dim N As Long, i As Long, BigString As String
    N = Cells(Rows.Count, 1).End(xlUp).Row
    BigString = Range("A1").Value
    For i = 2 To N
        BigString = BigString & ";" & Cells(i, 1).Value
    Next i
    i = 1
    ary = Split(BigString, ";")
    For Each a In ary
        Cells(i, 2).Value = a
        i = i + 1
    Next a
End Sub

EDIT#1:

based on your need for the extra column, this macro asks for the initial value and places the results in columns A and B :

Sub ReArrangeII()
    Dim N As Long, i As Long, BigString As String
    Dim M As Long, j As Long
    N = Cells(Rows.Count, 1).End(xlUp).Row
    M = Application.InputBox(Prompt:="enter initial value", Type:=1)
    j = 1
    For i = 1 To N
        BigString = Cells(i, 1).Value
        ary = Split(BigString, ";")
        u = UBound(ary) + 1
        For Each a In ary
            Cells(j, 2).Value = M
            Cells(j, 3).Value = a
            j = j + 1
        Next a
        M = M + 1
    Next i
End Sub

相关问答

更多

最新问答

更多
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的
  • SimplePie问题(SimplePie Problem)
  • 在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)
  • HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)
  • 为什么我会收到链接错误?(Why do I get a linker error?)
  • 如何正确定义析构函数(How to properly define destructor)
  • 垂直切换菜单打开第3级父级。(Vertical toggle menu 3rd level parent stay opened. jQuery)
  • 类型不匹配 - JavaScript(Type mismatch - JavaScript)
  • 为什么当我将模型传递给我的.Net MVC 4控制器操作时,它坚持在部分更新中使用它?(Why is it that when I pass a Model to my .Net MVC 4 Controller Action it insists on using it in the Partial Update?)
  • 在使用熊猫和statsmodels时拉取变量名称(Pulling variable names when using pandas and statsmodels)
  • 如何开启mysql计划事件
  • 检查数组的总和是否大于最大数,反之亦然javascript(checking if sum of array is greater than max number and vice versa javascript)
  • 使用OpenGL ES绘制轮廓(Drawing Outline with OpenGL ES)
  • java日历格式(java Calendar format)
  • Python PANDAS:将pandas / numpy转换为dask数据框/数组(Python PANDAS: Converting from pandas/numpy to dask dataframe/array)
  • 如何搜索附加在elasticsearch索引中的文档的内容(How to search a content of a document attached in elasticsearch index)
  • LinQ to Entities:做相反的查询(LinQ to Entities: Doing the opposite query)
  • 从ExtJs 4.1商店中删除记录时会触发哪些事件(Which events get fired when a record is removed from ExtJs 4.1 store)
  • 运行javascript后如何截取网页截图[关闭](How to take screenshot of a webpage after running javascript [closed])
  • 如何使用GlassFish打印完整的堆栈跟踪?(How can I print the full stack trace with GlassFish?)
  • 如何获取某个exe应用程序的出站HTTP请求?(how to get the outbound HTTP request of a certain exe application?)
  • 嗨,Android重叠背景片段和膨胀异常(Hi, Android overlapping background fragment and inflate exception)
  • Assimp详细说明typedef(Assimp elaborated type refers to typedef)
  • 初始化继承类中不同对象的列表(initialize list of different objects in inherited class)
  • 使用jquery ajax在gridview行中保存星级评分(Save star rating in a gridview row using jquery ajax)
  • Geoxml3 groundOverlay zIndex(Geoxml3 groundOverlay zIndex)