有个表news,有三个字段:id title date。
如:1 abc 2008-11-01
2 sfs 2008-11-05
5 tygg 2008-11-07
......
我要删去表中日期大于2008-11-05的前50条记录,
delete from news where id IN (select id from news date>'2008-11-15' order by date desc limit 50)
这样写,对吗?但测试发现语句有错。请问如何写才是正确的?
如:1 abc 2008-11-01
2 sfs 2008-11-05
5 tygg 2008-11-07
......
我要删去表中日期大于2008-11-05的前50条记录,
delete from news where id IN (select id from news date>'2008-11-15' order by date desc limit 50)
这样写,对吗?但测试发现语句有错。请问如何写才是正确的?
delete from news where date>'2008-11-15' order by date desc limit 50
请教高手这样又如何写?
#1111 - Invalid use of group function
select count(*) from news where date>'2008-11-15' into @cnt;
delete from news where date>'2008-11-15' and @cnt > 100 order by date desc limit 50
delete from news where id IN (select top 50 id from news convert(varchar(8),date,112) >20081115 order by date desc )