mysql 刪除重複且保留最新那筆

請問一下 為什麼這段程式碼無法WORK

$del = mysql_query("
DELETE FROM notification
WHERE (from_id,get_id,text,beread,bepopup) in (SELECT from_id,get_id,text,beread,bepopup FROM notification
GROUP BY from_id,get_id,text,beread,bepopup HAVING COUNT(*) >1)
AND not in (ORDER BY time DESC LIMIT 1)
");

我是要假設這五個欄位(from_id,get_id,text,beread,bepopup)值都一樣
則刪除最舊的筆數只留最新(time)那筆
標籤:
Sign In or Register to comment.