Question

Find all facilities whose name begins with 'Tennis'. Retrieve all columns.
Schema reminder
DB schema

Expected Results

facid name membercost guestcost initialoutlay monthlymaintenance
0 Tennis Court 1 5 25 10000 200
1 Tennis Court 2 5 25 8000 200

Your Answer Hint Help Save Run Query


              

Answers and Discussion Show

select * from cd.facilities where name like 'Tennis%';          

The SQL LIKE operator is a highly standard way of searching for a string using basic matching. The % character matches any string, while _ matches any single character.

One point that's worth considering when you use LIKE is how it uses indexes. If you're using the 'C' locale, any LIKE string with a fixed beginning (as in our example here) can use an index. If you're using any other locale, LIKE will not use any index by default. See here for details on how to change that.

Use the LIKE operator.

Keyboard shortcuts:


Other hints: