Removing duplicate MySQL distinct

If the semantic organization of information were embodied in reality, then the scope of the MySQL distinct construct would instantly self-destruct. Modern databases are built as part of a relational relationship between data, so the task of removing duplicate records is relevant.

Mysql distinct




The appearance of identical rows, as a rule, is not a problem that cannot be solved, but to avoid duplication of the contents of the table fields is almost impossible in many cases.

Database organization

It is believed that the “correct” database contains unique tables, and each of them contains unique fields. The presence of the same content in the fields of different tables is allowed only if they are key and a logical connection of data is carried out on them.

, . , , .

MySQL distinct , .





. , , , . ( ).

. , , , , . , , , .

mysql query select distinct




, MySQL distinct. «» - . , . MySQL distinct : .





, , . , , .

MySQL query "select distinct ..."

, : . :

  • ;
  • ;
  • .

, .

Author's example is not a picture




. , .

However, it is always preferable to simplify the work with the database. Using MySQL distinct on one field is always preferable to working on several.

mysql distinct one field




It is especially important to carefully compile queries that combine multiple tables. Any combination of data in relational databases before the where and join constructions begin to function results in large amounts of data. Orientation in them requires attention and accuracy from the developer.




All Articles