· 4 years ago · Feb 24, 2021, 09:22 AM
1create table IF NOT EXISTS table_a
2(
3 id serial primary key not null,
4 title varchar(100) not null,
5 author varchar(50),
6 price float not null
7);
8
9create table IF NOT EXISTS table_b
10(
11 id serial primary key not null,
12 title varchar(100) not null,
13 author varchar(50),
14 price float not null
15);
16
17insert into table_a(title, author, price)
18values ('Harry Potter e il prigioniero di Azkaban.', 'J. K. Rowling', 21.75);
19
20insert into table_b(title, author, price)
21values ('Titolo del libro', 'autore', 0);
22
23update table_b b
24set title = a.title,
25 author = a.author,
26 price = a.price
27from table_a a
28where b.id = a.id;