Skip to content
Worked Examples · Example 9

Q.Write an SQL query to display the Name and City of all customers who live in 'Pune' from the Customer table.

Maharashtra MsbshseTextbookSubjectiveImportance★★★★★est
86% · 12/14 Questions
✓ Free question

The SELECT statement reads data from a table. Two things are needed here:

  1. Choosing columns: only Name and City are wanted, so we name those two columns after SELECT (not *).
  2. Choosing rows: only customers of Pune are wanted, so we add a WHERE clause with the condition City = 'Pune'. The text value is written inside single quotes.

The complete query is:

SELECT Name, City FROM Customer
WHERE City = 'Pune';

This lists the name and city of only those customers whose city is Pune. If every column of those rows were wanted, we would instead write SELECT * FROM Customer WHERE City = 'Pune';.

✓Final answer

SELECT Name, City FROM Customer
WHERE City = 'Pune';

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.