Merge Into For Update Example
Merge Into article aa Using ( SELECT md5_id, Min(article_id) as Min_Article_ID from article WHERE created_time between (sysdate-10/(24*60)) and sysdate and Min_Article_ID is null GROUP BY md5_id HAVING COUNT(*)>1 ) sr ON (aa.md5_id=sr.md5_id) WHEN MATCHED THEN UPDATE SET aa.Min_Article_ID=sr.Min_Article_ID,aa.samilar_record_count=1 Where aa.created_time between (sysdate-10/(24*60)) and sysdate And aa.Min_Article_ID is null;