Wild Cards & Distinct

Wild Cards

Used to replace one or more characters

% wild card to replace more than one character

_ wild card to replace one character.

-- Starting with character 'A'

select FirstName from Chinook.Customer where FirstName like 'A%';

Distinct

Distinct is used to get a unique set of records from a table.

-- select distinct column1 from table;

-- Table Alias
select FirstName from Chinook.Customer c order by FirstName;

-- Table Alias
select distinct FirstName from Chinook.Customer c;

Distinct and NULL

MySQL keeps one NULL value and eliminates the other because the DISTINCT clause treats all

NULL values as the same value.

Distinct with Multiple Columns

select FirstName,LastName from Chinook.Customer;

Last updated