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

I'm pretty sure my code is right. It's giving me an error. Any clues?

UPDATE phone_book SET first_name = "Mystery" AND last_name = "Person";

Here's the original question...

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. Update all contacts to have the first name of "Mystery" and last name of "Person".

4 Answers

Try: UPDATE phone_book SET first_name = "Mystery", last_name = "Person";

Change "AND" for ","

Laurie Gray
Laurie Gray
23,119 Points

Thank you Jorge :) Sometimes you pour over things for ages, then realise it could all have been solved with a comma. :)

derek fentress
derek fentress
737 Points

i did exactly that and still says its wrong update phone_book set first_name="Mystery", last_name="person" still showing as wrong

chase singhofen
chase singhofen
3,811 Points

idk why we cant use AND instead of comma

I'd also like clarification why!

Laszlo Fazekas
Laszlo Fazekas
815 Points

Wondering, but maybe the answer is: the challange asks to modify ALL data in the phone_book. So, if you have John Doe and Jane Doe in your phone book, both will get the same name for different phone numbers. The name will be: Mystery Person. So, the solution: UPDATE phone_book SET first_name = "Mystery", last_name = "Person";

If you want to use AND you should use first WHERE condition. But for this you should first give for what to change it. In this case you have missing the information to put after SET command if you want to use WHERE and AND commands. For example: if the challange would ask to change John Doe's name to Al Pacino in every records, you could use WHERE command: UPDATE phone_book SET first_name = "Al", last_name = "Pacino" WHERE first_name = "John" AND last_name= "Doe"; This would not modify the name of Jane Doe.

You're missing the 's' in phone_books

UPDATE phone_books SET first_name = "Mystery" AND last_name = "Person";
Christian A. Castro
Christian A. Castro
30,501 Points

Xayaseth Boudsady You don't need to add 's to the table, phone_book is perfectly fine! just remove the 'AND'/replace it for ,

It should work:

UPDATE phone_book SET first_name = "Mystery", last_name = "Person";