我有两个表,他们有相同的ID名称(我不能改变表的设计方式),我试图查询table2的ID,我怎么会这样做,当他们是加入?同名Postgresql调用列
create table table1(
id integer, -- PG: serial
description MediumString not null,
primary key (id)
);
create table table2 (
id integer, -- PG: serial
tid references table1(id),
primary key (id)
);
所以当他们参加基本,两列具有相同的名称“ID”如果我做下面的查询
select * from table1
join table2 on table1.id = table2.tid;
对于其他任何事情,SELECT *通常都是个坏主意;如果您使用它,基于模式更改,事情可能会以不可预知和令人惊讶的方式突破。 – kgrittn 2012-04-22 15:55:44