Skip to content
Advertisement

Can’t remove duplicates from MariaDB 10

I’m having hard time removing duplicates from database. It’s MariaDB (protocol version: 10, 10.3.34-MariaDB Server). I need to remove rows where three columns are equal. I was trying to use WITH clause but database throws error that it can’t recognize ‘WITH’, so I focused on traditional way.

I need to remove rows where foreignId, column1 and column2 are equal.

I’m checking if there are duplicates like

Trying to remove duplicates…

I was modifying this code alot but still can’t make it work as intended… What am I doing wrong?

Advertisement

Answer

Assuming you have a unique column like id, you can do following:

Please see the working example here: db<>fiddle

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement