利用SQL查询语句来删除记录出错,请帮忙.谢谢!

来源:百度知道 编辑:UC知道 时间:2024/05/13 07:48:35
delete from employeeconsume a
(
select *
from employeeconsume a
where exists(select * from employeeconsume where ConsumeType=a.ConsumeType and ConsumeItem=a.ConsumeItem and employeeid=a.employeeid and DateInfo>=dateadd(minute,-60,a.DateInfo)
and DateInfo<a.DateInfo and property='0 - 合法卡')
)

出错提示:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'a'.
还是不行哦~
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'a'.

当然出错了,语法都不通过啊
delete from employeeconsume where id in
(
select id
from employeeconsume a
where exists(select * from employeeconsume where ConsumeType=a.ConsumeType and ConsumeItem=a.ConsumeItem and employeeid=a.employeeid and DateInfo>=dateadd(minute,-60,a.DateInfo)
and DateInfo<a.DateInfo and property='0 - 合法卡')
)
id为虚拟字段,你可改成你所需要的查询的条件字段名,再试一下