I am using this query to get all non duplicate entrys in a database:
SELECT title, COUNT(title) as cnt
FROM my_table.books
GROUP BY title
HAVING cnt > 1
ORDER BY cnt;
I created a new column no_duplicate of type tinyint(1) in which I want to mark every row as 1, that is unique (every output of the query above).
Is it possible to nest an Update with the query above? Or is there an even more elegant way?
This will do it:
I did it in two steps for efficiency, since it is much more likely to have no duplicates (reasonable assumption), the
WHERE title INlist will be small and therefore fast.