一个数据去重sql

参考:

https://www.jb51.net/article/129656.htm

DELETE testcase
FROM
 testcase,
 (
  SELECT
  max(id) id,
  api_purpose,
api_host,
request_url,
  request_data,
assert_method,
check_point,
correlation,
active,
creater
  FROM
   testcase
  GROUP BY
  api_purpose,
api_host,
request_url,
  request_data,
assert_method,
check_point,
correlation,
active,
creater
  HAVING
   count(*) > 1
 ) t2
WHERE
 testcase.api_purpose = t2.api_purpose
 and testcase.api_purpose = t2.api_purpose
 and testcase.api_host = t2.api_host
 and testcase.request_url = t2.request_url
 and testcase.request_data = t2.request_data
 and testcase.assert_method = t2.assert_method
 and testcase.check_point = t2.check_point
 and testcase.correlation = t2.correlation
 and testcase.active = t2.active
 and testcase.creater = t2.creater
 and testcase.id <t2.id;

原文地址:https://www.cnblogs.com/kaerxifa/p/10900661.html