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 trialAndrew Cottage
20,718 PointsRemove 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
42,016 Pointsis 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";
Andrew Cottage
20,718 PointsThanks 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
3,779 PointsI had the same problem. What worked for me was DELETE FROM movies WHERE year=1985; (I left out the star).
Ary de Oliveira
28,298 PointsChallenge 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";
Andrew Cottage
20,718 PointsThanks 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
42,016 Pointshmm could you provide a link to the challenge please
Andrew Cottage
20,718 PointsThanks for your help!
Christopher Hall
9,052 PointsThe 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
2,304 PointsI 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;
Andrew Cottage
20,718 PointsHey Jonathan, I tried it with movies having single quotes, and still got the same response.
Jonathan Baker
2,304 PointsAndrew Chalkley any thoughts?
Philip Allen
8,171 PointsHello
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
2,304 PointsThe 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
2,304 PointsThe 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
2,304 PointsSorry for duplicate post, something went wrong with the forum editor. =(
Rachman Walker
12,517 PointsThis 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
11,266 PointsSeriously?? 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!
MUZ140592 Victor Mutasa
4,260 Pointsthis should work DELETE FROM 'movies' WHERE year=1985;
A X
12,842 PointsA X
12,842 PointsNow interestingly for me your response worked whereas if I put the year as an INT, the code doesn't "pass"....very interesting!