I have a table named content with the following fields: id (key), title, alias, state and hits.
There are many duplicated records (different ids, but same title and same alias). The "state" field controls if a record is Published (1) or Unpublished (0).
At the moment I was able to unpublish duplicated records:
UPDATE content
SET content.state = 0
WHERE content.alias IN
(
SELECT alias FROM
(
SELECT `alias`, COUNT(*) `tot`
FROM `content`
GROUP BY `alias`
HAVING `tot` > 1
) AS tmptable
)
but this doesn't take into account which record has the greater "hits".
My goal is to unpublish duplicated records with smaller hits.