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;
posted on 2013-07-03 15:37  思静  阅读(285)  评论(0编辑  收藏  举报