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:
- Choosing columns: only
NameandCityare wanted, so we name those two columns afterSELECT(not*). - Choosing rows: only customers of
Puneare wanted, so we add aWHEREclause with the conditionCity = '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.