Non-repeated query in MySQL is an important query method in MySQL. The following describes how to implement non-repeated query in MySQL.
No duplicate query in MySQL is a unique query, that is, the query results that meet the conditions but are different from each other. First, let's look at an example:
- select title from employee_data;
-
- +----------------------------+
- | title |
- +----------------------------+
- | CEO |
- | Senior Programmer |
- | Senior Programmer |
- | Web Designer |
- | Web Designer |
- | Programmer |
- | Programmer |
- | Programmer |
- | Programmer |
- | Multimedia Programmer |
- | Multimedia Programmer |
...
In the preceding example, We query the title (title) in the employee_data table and note that many of the results are duplicated. If we want to get a non-repeated result, we can use the mysql keyword-DISTINCT.
- select DISTINCT title from employee_data;
-
- +----------------------------+
- | title |
- +----------------------------+
- | CEO |
- | Customer Service Manager |
- | Finance Manager |
- | Marketing Executive |
- | Multimedia Programmer |
- | Programmer |
- | Senior Marketing Executive |
- | Senior Programmer |
- | Senior Web Designer |
- | System Administrator |
- | Web Designer |
- +----------------------------+
- 11 rows in set (0.00 sec)
-
In this way, all the company's job categories can be listed without review. In addition, we can also use DISTINCT and ordber by to sort unique (non-duplicated) results, for example:
- select DISTINCT age from employee_data
- ORDER BY age;
-
- +------+
- | age |
- +------+
- | 25 |
- | 26 |
- | 27 |
- | 28 |
- | 30 |
- | 31 |
- | 32 |
- | 33 |
- | 34 |
- | 35 |
- | 36 |
- | 43 |
- +------+
- 12 rows in set (0.00 sec)
-
-
-
Introduction to transcoding in mysql command line cmd Environment
Mysql command line parameters
Two methods to fix mysql tables
How to insert an array into a mysql table in php
MySQL table management commands