Reputation: 73
I am trying to update the title of a publication and the year of the journal (corresponding to it). Do I need to do two separate queries? Or can I do this in one query?
%%sql
/* Change the title of an article and its publication year. */
UPDATE publication
SET title = "Sleepy", year = 2017
JOIN journal
ON publication.ID = journal.ID
WHERE title = "test title";
Upvotes: 0
Views: 25
Reputation: 2423
See if this works. It's confusing what columns belong to which table without a schema.
UPDATE publication
SET title = "Sleepy", year = 2017
WHERE title = "test title" and ID in (Select ID From journal);
Upvotes: 0
Reputation: 101
You can use this syntax to update multiple tables:
UPDATE table1, table2, ... SET column1 = expression1, column2 = expression2, ... WHERE table1.column = table2.column [AND conditions];
Upvotes: 1