I have a table with the following columns:
URL_ID
URL_ADDR
URL_Time
I want to remove duplicates on the URL_ADDR
column
This will leave the ones with the highest URL_ID
for a particular URL_ADDR
DELETE FROM table
WHERE URL_ID NOT IN
(SELECT ID FROM
(SELECT MAX(URL_ID) AS ID
FROM table
WHERE URL_ID IS NOT NULL
GROUP BY URL_ADDR ) X) /*Sounds like you would need to GROUP BY a
calculated form - e.g. using REPLACE to
strip out www see Daniel's answer*/
(The derived table 'X' is to avoid the error "You can't specify target table 'tablename' for update in FROM clause")