![]() ![]() Lastname Code language: SQL (Structured Query Language) ( sql )Ģ3 rows in set (0.00 sec) Code language: plaintext ( plaintext )Īs shown clearly in the output, some employees have the same last names e.g., Bondur,Firrelli. We’ll use the employees table from the sample database:įirst, select the last names from the employees table using the following SELECT statement: SELECT When executing the SELECT statement with the DISTINCT clause, MySQL evaluates the DISTINCT clause after the FROM, WHERE, and SELECT clause and before the ORDER BY clause: ![]() However, if you specify two or more columns, the DISTINCT clause will use the values of these columns to evaluate the uniqueness of the rows. If you specify one column, the DISTINCT clause will evaluate the uniqueness of rows based on the values of that column. In this syntax, you specify one or more columns that you want to select distinct values after the SELECT DISTINCT keywords. Sort_expression Code language: SQL (Structured Query Language) ( sql ) Here’s the syntax of the DISTINCT clause: SELECT DISTINCT To remove these duplicate rows, you use the DISTINCT clause in the SELECT statement. ![]() When querying data from a table, you may get duplicate rows. Summary: in this tutorial, you will learn how to use the MySQL DISTINCT clause in the SELECT statement to eliminate duplicate rows in a result set. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |