Introduction
Use DISTINCT to get only unique values from a list, removing any duplicates.
SELECT DISTINCT column_name FROM table_name;
SELECT DISTINCT country FROM customers;
SELECT DISTINCT product_name, category FROM products;
SELECT DISTINCT city FROM addresses;
CREATE TABLE employees (id INT, department VARCHAR(20)); INSERT INTO employees VALUES (1, 'Sales'), (2, 'HR'), (3, 'Sales'), (4, 'IT'), (5, 'HR'); SELECT DISTINCT department FROM employees;
DISTINCT keyword do in a MySQL query?customers?orders with a column product_id containing values: [1, 2, 2, 3, 1, 4], what will the query SELECT DISTINCT product_id FROM orders; return?customers table?SELECT DISTINCT name, age FROM customers;sales with columns region and salesperson. Some salespersons work in multiple regions. Which query will list all unique salespersons regardless of region?Pass the test and this pattern moves unknown