Samuel R. Neff wrote:
I would expect "SELECT T.*" to always return all fields from table T.
However this seems not to be the case when using natural join.

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

SQLite version 3.4.2
Enter ".help" for instructions
sqlite> create table a(aid integer);
sqlite> create table b(bid integer, aid integer);
sqlite> insert into a values (1);
sqlite> insert into b values (2, 1);
sqlite> select * from a natural join b;
aid         bid
----------  ----------
1           2
sqlite> select b.* from a natural join b;

I realize that in the natural join the field "aid" from the first "select *"
query is not considered to belong to either table a or table b, but still in
the second query, shouldn't "select b.*" include all fields from table b?


You have stated the answer yourself. The result of the natural join does not contain the columns from either table when there is a column with the same name in both tables. If you imagine the natural join columns coming from a pseudo table named j then the result has columns j.aid and When you select b.* from this result there is only one column from table b, the one sqlite returns.

Dennis Cote

To unsubscribe, send email to [EMAIL PROTECTED]

Reply via email to