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 trialAngela Poldervaart
3,192 PointsChallenge Task: Deleting Data with SQL
The task is:
Now we're using a database from a smartphone. It has a phone_book table. It has the columns id, first_name, last_name and phone. Delete all contacts with the first name of Jonathan and last name of Luna.
I don't know what I'm doing wrong:
DELETE FROM phone_book WHERE first_name = "Jonathan" AND last_name = "Luna";
DELETE FROM phone_book WHERE first_name = "Jonathan", last_name = "Luna";
I've tried both but both were wrong.
1 Answer
Steven Parker
231,271 PointsYou were right the first time. I even tested it by pasting your code line directly into the challenge and it passed.
Perhaps you are having a browser issue, try restarting your browser and see if that fixes it.
Angela Poldervaart
3,192 PointsAngela Poldervaart
3,192 PointsNow it worked! Good to know that I wasn't wrong :)
Thank you Steven!
nicolaspeterson
8,569 Pointsnicolaspeterson
8,569 PointsI don't understand why this works. The way I read the question, we may have several contacts with either that first name or last name. Using the AND operator requires that both conditions be met for the DELETE function to work. I tried separating the values with a comma hoping that would work, but it didn't until I used AND.
Steven Parker
231,271 PointsSteven Parker
231,271 PointsAs I told Angela, her first example is the correct syntax (using "AND" to combine comparisons). It's not correct to place a comma between two comparisons.