Writing Queries #14


#1

Return all movies that include 'King' in the name.

This step doesn't want us just to return entries with King with the K capitalized, does it? That wasn't taught in the lesson. I also tried collate, and it doesn't seem to work in the Codecademy environment.


#2

I interpreted it to mean that we should use LIKE. So we end up with both King and king.


#3

The instructions could be better. Not capitalizing the King like this

Return all movies that include 'king' in the name.

Would be slightly better. Mentioning not caring for case sensitivity would be good, too.


#4

Hi,

I was working on this problem too, and wrote this:

select * from movies where name like '%King%';

The result included titles such as "Look who's talking". How can I get a result that does not include text such as talking, breaking, etc?


#5

Don't use the % symbols. They are saying "match 0 or more characters here".


#6

Thank you for the answer. But I do want to return rows with the word "King" in them.

For example, return "King Kong" and "Lion King" but not return "Wal**king** Dead"


#7

This is a start:

SELECT * FROM movies
WHERE name LIKE 'king'
OR name LIKE 'king %'
OR name LIKE '% king'
OR name LIKE '% king %';

If king had a some other punctuation, like a comma, instead of a space then that instance is not going to get caught with that search.