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

Databases Modifying Data with SQL Deleting Data From a Database Deleting Data With SQL

Angela Poldervaart
Angela Poldervaart
3,192 Points

Challenge 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
Steven Parker
229,644 Points

You 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
Angela Poldervaart
3,192 Points

Now it worked! Good to know that I wasn't wrong :)

Thank you Steven!

I 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
Steven Parker
229,644 Points

As 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.