删除查询失败:“ DELETE”附近:语法错误

时间:2020-02-10 04:39:52

标签: sql sql-delete

我正在执行一个查询,该查询应该删除包含特定字符串的行:

DELETE FROM Event 
WHERE EventMessage LIKE '%Missing format string - selector:%' 
IN
Select WhenOccurred,EventMessage
From Event
Where WhenOccurred > DateFunc('now', -1)

我查看了有关删除和点赞语句的所有文档,但是我不知道为什么会出现此错误:

查询失败:“ DELETE”附近:语法错误

2 个答案:

答案 0 :(得分:0)

MySQL:

DELETE FROM Event 
WHERE EventMessage LIKE '%Missing format string - selector:%' ;

Select WhenOccurred,EventMessage
From Event
Where WhenOccurred >  NOW() - INTERVAL 1 DAY

答案 1 :(得分:0)

您的问题似乎不完整

如果您只想删除具有事件消息(例如'%Missing格式字符串-选择器:%')的记录,则仅运行第一个查询

DELETE FROM Event 
WHERE EventMessage LIKE '%Missing format string - selector:%' 

或者如果您想添加更多条件,例如最近24小时内发生的删除事件

DELETE FROM Event 
WHERE EventMessage LIKE '%Missing format string - selector:%' and WhenOccurred >= DATEADD(hh, -24, GETDATE())