SQLの表の同じ列で重複した値を削除する
時々、テーブルは文字列、数またはetcとして複製値を持ちます.そして、我々はそのデータをきれいにしたいです.しかし、データの動的なので、テーブルのすべてのケースのハードコードをすることはできません.
ID
名称
1
オレンジ🍊
2
アップル🍎
3
オレンジ🍊
4
パイナップル🍍
この場合、以下のような単純なSQLを持っています.
ID
名称
1
オレンジ🍊
2
アップル🍎
4
パイナップル🍍
Find out USING in this article
楽しむ時間🪴
読書ありがとう.
fruits table
ID
名称
1
オレンジ🍊
2
アップル🍎
3
オレンジ🍊
4
パイナップル🍍
この場合、以下のような単純なSQLを持っています.
DELETE
FROM fruits a
USING fruits b
WHERE a.id > b.id
AND a.name = b.name;
Result after excute query
ID
名称
1
オレンジ🍊
2
アップル🍎
4
パイナップル🍍
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
楽しむ時間🪴
読書ありがとう.
Reference
この問題について(SQLの表の同じ列で重複した値を削除する), 我々は、より多くの情報をここで見つけました https://dev.to/hte305/delete-duplicate-value-in-the-same-column-sql-47dテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol