Search Postgresql Archives

select t.name from tbl t (where "name" is not a column name)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,

i've just noticed the following behaviour and was wondering
if there's any documentation to explain what it's for.

  create table tbl(id serial primary key, a text, b text, c text);
  insert into tbl(a, b, c) values ('abc', 'def', 'ghi');
  insert into tbl(a, b, c) values ('jkl', 'mno', 'pqr');
  insert into tbl(a, b, c) values ('stu', 'vwx', 'yza');
  select t.name from tbl t;
  drop table tbl;

results in:

        name       
  -----------------
   (1,abc,def,ghi)
   (2,jkl,mno,pqr)
   (3,stu,vwx,yza)

you can select t.name from tbl t even though "name" isn't the name
of a column in the table and you get this tuple-like version of the
each row. it doesn't work without the "t" alias and of course it
doesn't work if name really is the name of a column in the table.

so, what's this behaviour for, and, is there an equivalent
way to do it when "name" is the name of a column? i doubt
that i need this behaviour for anything. i'm just curious
and didn't see any mention of this in the documentation for
the select statement.

cheers,
raf


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux