Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Remove all movies from the year 1985 from the movies table.

Hello.

I haven't been able to make the third code challenge task pass.

I'm inputting

DELETE FROM movies WHERE year =1985; 

11 Answers

Stone Preston
Stone Preston
42,016 Points

is year a string possibly? I havent done any of the database tracks so I really have no idea, just throwing out a suggestion.

maybe try

DELETE FROM movies WHERE year = "1985";

Now interestingly for me your response worked whereas if I put the year as an INT, the code doesn't "pass"....very interesting!

Thanks everyone. I tried the code challenge again, bu this time from the beginning and it worked with my original code. I think it was just a treehouse glitch. I appreciate all of the responses.

Michele Swensen
Michele Swensen
3,779 Points

I had the same problem. What worked for me was DELETE FROM movies WHERE year=1985; (I left out the star).

Challenge Task 1 of 3

Insert a new row into the movies table where the title is the string 'Aliens' and the year is an integer 1986.

INSERT INTO movies (title, year) VALUES ("Aliens", 1986);

Challenge Task 2 of 3

Update the film 'Alien' to have the year 1979.

update movies set year = 1979 where title = 'Alien';

Challenge Task 3 of 3

Remove all movies from the year 1985 from the movies table.

DELETE FROM movies WHERE year = "1985";

Thanks for the response Stone.

I tried it as a string and it still returns:

Bummer! You didn't delete just the movies from 1985.

Stone Preston
Stone Preston
42,016 Points

hmm could you provide a link to the challenge please

Thanks for your help!

Christopher Hall
Christopher Hall
9,052 Points

The extra white space between year and the equals sign shouldn't matter, but it might be throwing the code checker for a loop. From the previous challenge steps it can be inferred that the year is an integer type, not a string. So we don't need quotes around it.

Your code in the original question does look correct.

Jonathan Baker
Jonathan Baker
2,304 Points

I just tried the challenge with the SQL you provided and it worked for me...

Make sure the table name is surrounded with single quotes?

DELETE FROM 'movies' WHERE year=1985;

Hey Jonathan, I tried it with movies having single quotes, and still got the same response.

Philip Allen
Philip Allen
8,171 Points

Hello

You need to let SQL know what you are trying delete. You want to delete everything from the year 1985 so you need to add the wildcard for all.

The command should be.

'''DELETE * FROM movies WHERE year=1985'''

Also don't leave a space between year and equals.

Hope this helps.

Jonathan Baker
Jonathan Baker
2,304 Points

The wildcard is unnecessary for DELETE commands. The DELETE command will delete all rows from the specified table that matches the predicate dictated by the WHERE clause. If not WHERE clause is given, then all rows from the table will be deleted, effectively the same as the TRUNCATE command.

Jonathan Baker
Jonathan Baker
2,304 Points

The wildcard is unnecessary for DELETE commands. The DELETE command will delete all rows from the specified table that matches the predicate dictated by the WHERE clause. If no WHERE clause is given, then all rows from the table will be deleted, effectively the same as the TRUNCATE command.

Jonathan Baker
Jonathan Baker
2,304 Points

Sorry for duplicate post, something went wrong with the forum editor. =(

This is a problem with the Treehouse challenge app, and they really should do some debugging or additional testing on this...I have an instance of mySQL installed on my laptop and all of my insert, update, and delete statements (i.e., syntax) are working fine in my mySQL instance, but not in the Treehouse challenge.

C'mon Treehouse, I think you can do better than this!

Seth Barthen
Seth Barthen
11,266 Points

Seriously?? What the hell... how has this still not been resolved? I'm trying every which way and it is not working for me either.

This is really frustrating as we all pay 25 if not more dollars a month for this service. These "teachers" are always sending me canned emails saying "anytime you have a question just ask me!!!!!" Yet, I have never received a response from them when it's needed nor does it look like they reach out to anyone else as someone already called out Andrew.

Best part is I can't even continue because it's saying the answer is wrong and won't let me continue!

So as I sit here with a buggy quiz and no option to continue forward... maybe I'll just have to cancel subscription.

P.S. It'd be nice for the markdown cheat sheet to show how to "call out people", but I'd imagine they'd rather not tell us and pass the buck.

SWEET!

this should work DELETE FROM 'movies' WHERE year=1985;