SQL Quest › SQL Interview Questions › Querying Basics

Pattern Matching with LIKE

EasyFreeQuerying Basics

Find all passengers whose name contains 'Mrs.' — these are married women. Show name, age, pclass, and survived. Sort by age descending. Limit to 15 rows. The % wildcard matches any number of characters.

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect". Free accounts get 10 free challenge solves, and this can be one of them.

Schema

passengers

passenger_idsurvivedpclassnamesexagesibspparchfareembarked
103Braund, Mr. Owen Harrismale22107.25S
211Cumings, Mrs. John Bradleyfemale381071.28C
313Heikkinen, Miss. Lainafemale26007.93S

Expected output: Appears because name contains 'Mrs.'

Hint

WHERE name LIKE '%Mrs.%' — the % before and after means 'Mrs.' can appear anywhere in the name.

Concepts

SELECT WHERE LIKE

Practise the topic: SQL practice questions

Read the concept: Learn SQL for beginners

Related questions

The IN OperatorEasy · FreeSorting and LimitingEasy · FreeDISTINCT ValuesEasy · FreeRecent Hit Movies (2010s)Easy · FreeWorking-Age Passengers (BETWEEN)Easy · FreeNon-Sales Roster (NOT IN)Easy · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test