Databases Modifying Data with SQL Updating Data in a Database Updating Data With SQL

Daniel Cronin
Daniel Cronin
4,466 Points

As far as I can tell I am correctly updating the rows in the table but the Challenge Task keeps failing.

I have tried update phone_book set (first_name, last_name) = ('Mystery', 'Person');

AND

update phone_book set first_name = 'Mystery'; update phone_book set last_name = 'Person';

1 Answer

Steven Parker
Steven Parker
203,753 Points

You're close, and your second try would actually work in practice. But the challenge wants you to to construct a single query that sets both values.

To set multiple values at a time, you can just separate them by commas. Here's a generic example:

UPDATE table SET field1 = value1, field2 = value2;
Daniel Cronin
Daniel Cronin
4,466 Points

Thank you for the help. I could have sworn I tried that syntax originally but I guess not. Grouping with parentheses works in my IDE. Is it not correct syntax for SQLite?

Steven Parker
Steven Parker
203,753 Points

That would also work in practice, I'm not sure why it doesn't pass the challenge. But it's probably not the technique that was shown in the videos.

I'd normally suggest submitting a bug report, but considering the recent changes, I suspect there's nobody to handle it.