w3resource
SQL exercises

SQL: Using where clause with like operator to filter records

SQL Wildcard & Special Operator : Exercise-10 with Solution

Write a SQL statement to find all those customers with all information whose names are ending with the letter 'n'.

Sample table: customer


Sample Solution :

SELECT *
FROM customer
WHERE cust_name LIKE '%n';

Output of the Query:

customer_id	cust_name		city	grade	salesman_id
3008		Julian Green		London	300	5002
3004		Fabian Johnson		Paris	300	5006
3009		Geoff Cameron		Berlin	100	5003
3001		Brad Guzan		London		5005

Explanation :

Syntax of filter records using where clause with like operator

Pictorial presentation :

Result of filter records using where clause with like operator

Query Visualization:

Duration:

Query visualization of Using where clause with like operator to filter records - Duration

Rows:

Query visualization of Using where clause with like operator to filter records - Rows

Cost:

Query visualization of Using where clause with like operator to filter records - Cost

 

Practice Online


Contribute your code and comments through Disqus.

Previous: Write a SQL statement to find that customers whose name begin with the letter 'B'.
Next: Write a SQL statement to find those salesmen with all information whose name containing the 1st character is 'N' and the 4th character is 'l' and rests may be any character.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming