|
Custom Search
| |
|
Eliminating Duplicate Rows When the result set from a SELECT statement contains duplicate rows, you may want to remove them and keep every row data to be unique for a column or combination of columns. You can use the DISTINCT or DISTINCTROW identifier to eliminate duplicate records. DISTINCT and DISTINCTROW are synonyms and specify removal of duplicate rows from the result set. Read Prerequisites for this tutorial and practices if you haven't done so. Consider the following facts when using DISTINCT or DISTINCTROW identifier in a SELECT statement:
Most of the queries in the tutorials need Northwind MySQL database, you can download the database script on this page. Practice #1: Retrieve distinct rows for one column. -- Display distinct Quantity values The query above retrieves distinct quantity data from order_details table. There are total 55 rows retrieved out of 2,155 rows in order_details table.
Query result set: Practice #2: Retrieve distinct rows for the combination of two columns. -- Retrieve distinct rows based on There are total 238 rows retrieved out of 2,155 rows in order_details table.
Query result set: Practice #3: Retrieve distinct rows for the combination of three columns. -- Retrieve distinct rows based on three There are total 1,711 rows retrieved out of 2,155 rows in order_details table.
Query result set: Other tutorials in this category 1. The Basic SELECT Statement |
Copyright © 2024 GeeksEngine.com. All Rights Reserved. This website is hosted by HostGator. No portion may be reproduced without my written permission. Software and hardware names mentioned on this site are registered trademarks of their respective companies. Should any right be infringed, it is totally unintentional. Drop me an email and I will promptly and gladly rectify it. |
Home | Feedback | Terms of Use | Privacy Policy |