Databases Modifying Data with SQL Deleting Data From a Database Review and Practice

Database: how to remove more than one actors?

In the exercise for removing data in - Remove actors with the first name "Yuri", "Walter" and "Victor".

My input is:

DELETE FROM actors WHERE name LIKE ("Yuri%" AND "Walter%" AND "Victor%);

Is the the correct format?

2 Answers

Steven Parker
Steven Parker
207,999 Points

You can't combine just terms with AND.

And AND is for requiring all conditions at once, OR is for any one of the conditions.

But you can combine complete expressions:

... name LIKE "Yuri%" OR name LIKE "Walter%" OR name LIKE "Victor%";

Would this also delete the actresses named "Victoria"?

Steven Parker
Steven Parker
207,999 Points

It would! So perhaps a better solution would be to include a space between the name and the "%" symbol.

Matthew Wilkes
Matthew Wilkes
4,809 Points

I used the below and this seemed to work for me:

DELETE FROM actors WHERE name IN ("Yuri", "Walter", "Victor")
Steven Parker
Steven Parker
207,999 Points

Sure, but you can't use the wildcard "%" when using the membership operator ("IN"). It only works with "LIKE".
The "IN" operator only works with exact matches.

But as you discovered, wildcards are not needed for this challenge.

Joseph Lander
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Joseph Lander
Front End Web Development Techdegree Graduate 24,869 Points

That didn't work for me? Names starting with "Yuri" are still there. Doesn't this mean it is looking for an exact match? It won't be as there is a lastname.