Blank output when adding UPDATE clause

When I add an update the output goes blank. This is the lesson:
Working With Your First Database | Codecademy

And this is my code, it does not even work by id as the video shows. Any help is appreciated.

CREATE TABLE friends (
id INTEGER,
name TEXT,
birthday DATE
);

INSERT INTO friends (id, name, birthday)
VALUES (1, ‘Jane Doe’, ‘1990-05-30’);

INSERT INTO friends (id, name, birthday)
VALUES (2, ‘Prahlad’, ‘2011-03-23’);

INSERT INTO friends (id, name, birthday)
VALUES (3, ‘Uma’, ‘2014-05-24’);

UPDATE friends
WHERE name = ‘Jane Doe’
SET name = ‘Jane Smith’;

ALTER TABLE friends
ADD COLUMN email TEXT;

UPDATE friends
SET email = ‘prahlad@gmail.com’
WHERE id = 2;

UPDATE friends
WHERE name = ‘Uma’
SET email = ‘uma@gmail.com’;

SELECT * from friends;

Hello, and welcome to the forums!

From my experience, when the learning environment output goes blank when working on SQL exercises, then there is a syntax error and/or invalid SQL. There isn’t great error message reporting like you may get using other tools.

Since you already pinpointed that adding the UPDATE portion is what caused it, we can focus on those:

UPDATE friends
WHERE name = 'Jane Doe'
SET name = 'Jane Smith';

UPDATE friends
SET email = 'prahlad@gmail.com'
WHERE id = 2;

UPDATE friends
WHERE name = 'Uma'
SET email = 'uma@gmail.com';

The WHERE clause should come after the SET portion of your SQL statements. You did it correctly for the 2nd one.

1 Like