Sometime, the table has duplicate value as string, number or etc,... And we want to clean that data. But the data is dynamic so we can not hard code for all case of table.
fruits table
id | name |
---|---|
1 | Orange ๐ |
2 | Apple ๐ |
3 | Orange ๐ |
4 | Pineapple๐ |
In this case, we got have a simple sql like that:
DELETE
FROM fruits a
USING fruits b
WHERE a.id > b.id
AND a.name = b.name;
Result after excute query
id | name |
---|---|
1 | Orange ๐ |
2 | Apple ๐ |
4 | Pineapple๐ |
If several columns have the same names but the datatypes do not match, the NATURAL JOIN clause can be modified with the USING clause to specify the columns that should be used for an EQUIJOIN.
Find out USING in this article
Enjoy your time ๐ชด
Thanks for reading.
Top comments (1)
Here's another approach: