I'm a novice SQL user, and I'm confused by an apparently arbitrary limitation on multiple inner joins. I'm able to use the "using" clause for the first join but not for the second. I assume that I'm doing something silly out of ignorance. Any explanation for this behavior will be greatly appreciated.

create table aa (i integer, j integer);
create table bb (i integer);
create table cc (j integer);

insert into aa values (1,2);
insert into aa values (3,4);
insert into aa values (5,6);

select * from aa;
i     j
----  ------------
1     2
3     4
5     6

insert into bb values (1);
insert into bb values (5);

select * from bb;
i
----
1
5

select * from aa inner join bb using (i);
aa.i  aa.j
----  ------------
1     2
5     6

insert into cc values(6);
insert into cc values (7);
select * from cc;
j
----
6
7

select * from aa inner join bb using (i) inner join cc;
aa.i  aa.j          cc.j
----  ------------  ----------
1     2             6
1     2             7
5     6             6
5     6             7

select * from aa inner join bb using (i) inner join cc using (j);
SQL error: cannot join using column j - column not present in both tables


Thanks,

Rob.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to