Preamble
MySQL DISTINCT statement is used to remove duplicates from the result set. The DISTINCT operator may be used only with SELECT operators.
Syntax DISTINCT operator in MySQL
SELECT DISTINCT
FROM tables
[WHERE conditions];
Parameters and arguments of the operator
- expressions – columns or calculations that you want to get.
- tables – the tables from which you want to get the records. There must be at least one table listed in the FROM statement.
- WHERE conditions are optional. The conditions that must be met for the selected records.
Note:
- When only one expression is provided in DISTINCT, the query returns unique values for this.
- If more than one expression is present in DISTINCT, the query will receive unique combinations for the specified expressions.
- In MySQL, the DISTINCT operator does not ignore NULL values. Therefore when using DISTINCT in your SQL offer, your resulting set will include NULL as a separate value.
One-column example
Let’s consider a simple example of MySQL statement DISTINCT. We can use MySQL DISTINCT to return a single column that removes duplicates from the result set.
For example:
SELECT DISTINCT state
FROM customers;
This example MySQL DISTINCT returns all unique state values from the customer’s table.
Example with multiple columns
Let’s look at an example of how you can use the MySQL DISTINCT statement to remove duplicates from more than one column in a SELECT statement.
For example:
SELECT DISTINCT city, state
FROM customers;
This example of a DISTINCT MySQL statement returns each unique combination of city and state fields from the Customers table. In this case, DISTINCT applies to each column specified after the DISTINCT keyword and therefore returns individual combinations.
MySQL Tutorial for Beginners; MySQL SELECT DISTINCT Statement
About Enteros
Enteros offers a patented database performance management SaaS platform. It proactively identifies root causes of complex business-impacting database scalability and performance issues across a growing number of clouds, RDBMS, NoSQL, and machine learning database platforms.
The views expressed on this blog are those of the author and do not necessarily reflect the opinions of Enteros Inc. This blog may contain links to the content of third-party sites. By providing such links, Enteros Inc. does not adopt, guarantee, approve, or endorse the information, views, or products available on such sites.
Are you interested in writing for Enteros’ Blog? Please send us a pitch!
RELATED POSTS
How to Optimize Energy and Utilities Operations with Enteros Database Software, AI-Powered Analytics, and Database Observability
- 13 August 2026
- Database Performance Management
Introduction Energy and utility companies operate highly complex digital infrastructures supporting electricity generation, transmission, distribution, water services, natural gas, renewable energy, and customer operations. Every smart meter reading, grid event, outage record, customer payment, asset maintenance activity, and energy transaction generates data that must be processed efficiently. Enteros helps energy and utility organizations optimize database … Continue reading “How to Optimize Energy and Utilities Operations with Enteros Database Software, AI-Powered Analytics, and Database Observability”
How to Optimize Real Estate Operations with Enteros Database Software, AI-Powered Analytics, and Database Observability
Introduction Real estate organizations increasingly depend on digital platforms to manage property portfolios, transactions, leasing, facilities, tenants, financial operations, and customer experiences. Every property listing, lease transaction, maintenance request, payment, tenant interaction, and financial report depends on enterprise databases. Enteros helps real estate organizations optimize database performance through Database Observability, AI-powered Analytics, SQL Performance Intelligence, … Continue reading “How to Optimize Real Estate Operations with Enteros Database Software, AI-Powered Analytics, and Database Observability”
How to Optimize Higher Education Technology with Enteros Database Software, AI-Powered Analytics, and Database Observability
- 12 August 2026
- Database Performance Management
Introduction Universities and higher education institutions increasingly depend on digital infrastructure to manage student records, admissions, learning platforms, research systems, finance, housing, libraries, and campus services. Every student registration, tuition payment, course enrollment, examination record, research transaction, and digital learning interaction depends on enterprise databases. Enteros helps higher education institutions optimize these environments through Database … Continue reading “How to Optimize Higher Education Technology with Enteros Database Software, AI-Powered Analytics, and Database Observability”
Improving Healthcare IT Performance and Cost Efficiency with AIOps and FinOps
Introduction Healthcare organizations are undergoing rapid digital transformation. Electronic health records (EHRs), telemedicine platforms, patient portals, digital diagnostics, healthcare insurance applications, medical imaging systems, pharmacy platforms, and connected medical devices increasingly depend on complex IT infrastructure. At the same time, healthcare providers must deliver reliable digital services while controlling infrastructure costs. Even a short application … Continue reading “Improving Healthcare IT Performance and Cost Efficiency with AIOps and FinOps”