MySQL select query, we will perform below actions.
- List all customers who is active
- List all customers who is active and ‘Y’ in their firstname
- List all customers who is active and ‘Y’ in their lastname
- List all customers who having ‘Y’ in their lastname or lastname (either one)
- List all customers who having ‘Y’ in their lastname and lastname (in both)
List all customers who is active
SELECT * FROM customers where activeStatus ='Y';
![](http://www.learnwebtech.in/wp-content/uploads/2021/03/allquery-1024x159.png)
List all customers who is active and ‘Y’ in their firstname
SELECT * FROM customers where first_name LIKE '%Y%' AND activeStatus ='Y';
![](http://www.learnwebtech.in/wp-content/uploads/2021/03/firstname-y-1024x152.png)
List all customers who is active and ‘Y’ in their lastname
SELECT * FROM customers where last_name LIKE '%Y%' AND activeStatus ='Y';
![](http://www.learnwebtech.in/wp-content/uploads/2021/03/lastnamey-1024x159.png)
List all customers who having ‘Y’ in their lastname or lastname (either one)
SELECT * FROM `customers` WHERE (first_name LIKE'%Y%' OR last_name LIKE '%Y%') ORDER BY city ASC;
![](http://www.learnwebtech.in/wp-content/uploads/2021/03/firstorlasthavingy-1024x163.png)
List all customers who having ‘Y’ in their lastname and lastname (in both)
SELECT * FROM `customers` WHERE first_name LIKE'%Y%' AND last_name LIKE '%Y%' ORDER BY city ASC;
![](http://www.learnwebtech.in/wp-content/uploads/2021/03/bothhavingyy-1024x150.png)