【发布时间】:2011-03-16 10:46:09
【问题描述】:
Postgres:
create table stock(item_id int primary key, balance float);
insert into stock values(10,2200);
insert into stock values(20,1900);
select * from stock;
create table buy(item_id int primary key, volume float);
insert into buy values(10,1000);
insert into buy values(30,300);
select * from buy;
结果:
item_id | balance
---------+---------
10 | 2200
20 | 1900
(2 rows)
item_id | volume
---------+--------
10 | 1000
30 | 300
(2 rows)
现在我想要另一个包含这两个表数据的表。 新表有 3 行数据,item_id(10,20,30),没有重复
我需要对此进行查询;通过合并或加入。
【问题讨论】:
标签: postgresql join merge