The following SQL statement selects all customers with a CustomerName starting with “s”:
SELECT * FROM Customers
WHERE CustomerName LIKE ‘s%’;
The following SQL statement selects all customers with a CustomerName ending with “h”:
SELECT * FROM Customers
WHERE CustomerName LIKE ‘%h’;
The following SQL statement selects all customers with a CustomerName that have “ra” in any position:
SELECT * FROM Customers
WHERE CustomerName LIKE ‘%ra%’;
The following SQL statement selects all customers with a CustomerName that have “a” in the second position:
SELECT * FROM Customers
WHERE CustomerName LIKE ‘_a%’;
The following SQL statement selects all customers with a CustomerName that starts with “a” and are at least 3 characters in length:
SELECT * FROM Customers
WHERE CustomerName LIKE ‘a__%’;
The following SQL statement selects all customers with a ContactName that starts with “s” and ends with “h”:
SELECT * FROM Customers
WHERE ContactName LIKE ‘a%o’;
The following SQL statement selects all customers with a CustomerName that does NOT start with “a”:
SELECT * FROM Customers
WHERE CustomerName NOT LIKE ‘a%’;