Skip to main content

SQL: customer names beginning with su

Short answer

Use SELECT customer_name FROM Customer WHERE customer_name LIKE 'su%'; for case-insensitive matching, apply LOWER(customer_name) LIKE 'su%'.

Consider database schema: Account (acc_no, branch_name, balance) Branch (branch_name, branch_city, assets) Customer (customer_name, customer_street, customer_city) Loan (loan_no, branch_name, amount) Depositor (customer_name, acc_no) Borrower (customer_name, loan_no) List customer name whose name begins with 'su'.

Use the LIKE operator with the % wildcard (% matches any string of zero or more characters, _ matches exactly one character).

SELECT customer_name
FROM   Customer
WHERE  customer_name LIKE 'su%';

'su%' means: starts with "su", followed by anything.

Case matters in some systems. In standard SQL, Oracle and PostgreSQL, LIKE is case sensitive, so names stored as "Sujan" need 'Su%'. (MySQL with its default collation and SQLite ignore case.) To match either case in every system, write:

SELECT customer_name
FROM   Customer
WHERE  LOWER(customer_name) LIKE 'su%';

Sample (tested in SQLite): with customers Sujan, Ram and Suman, the query returns Sujan and Suman.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Database Management System chapter 3 questions →