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';

List all customers who is active and ‘Y’ in their firstname
SELECT * FROM customers where first_name LIKE '%Y%' AND activeStatus ='Y';

List all customers who is active and ‘Y’ in their lastname
SELECT * FROM customers where last_name LIKE '%Y%' AND activeStatus ='Y';

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;

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;
