Using 'LIKE' to search for a distinct word


<Below this line, add a link to the EXACT exercise that you are stuck at.>

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>

For task 14 of the queries project ‘Return all movies that include ‘King’ in the name.’ I’m getting all words that contain the 4 letters of king together, how would i look for rows where king is a distinct word? Adding a ‘%’ at either end works in excluding words where ‘king’ is part of another word (e.g ‘talking’) but also excludes results were ‘king’ is a unique word at the opposite end of the text string to the ‘%’

Instead of getting the following results

Indiana Jones and the Kingdom of the Crystal Skull
King Kong
Look Whos Talking
The Lion King
The Twilight Saga: Breaking Dawn - Part 1
The Twilight Saga: Breaking Dawn - Part 2

I’d just like to return ‘King Kong’ and ’ The Lion King’

<If you wish to copy/paste in your code, you can use this next section. This will allow others to copy/paste your code for testing – something that they won’t be able to do with just a screenshot.>


SELECT * FROM movies WHERE name LIKE ‘%King%’;

<do not remove the three backticks above>

Here is a discussion about the best way to do that:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.