table.column in query results?

Started by Andrew Klaassenover 16 years ago4 messagesgeneral
Jump to latest
#1Andrew Klaassen
clawsoon@yahoo.com

Hi,

Is it possible to get table.column in query results rather than just column?

I.e. I'd like:

SELECT * FROM foo, bar;
foo.id | foo.name | bar.id | bar.text
-------+----------+--------+---------
...

...rather than:

SELECT * FROM foo, bar;
id | name | id | text
---+------+----+-----
...

Thanks.

Andrew

__________________________________________________________________
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now
http://ca.toolbar.yahoo.com.

#2Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Andrew Klaassen (#1)
Re: table.column in query results?

Andrew Klaassen wrote:

Is it possible to get table.column in query results rather
than just column?

I.e. I'd like:

SELECT * FROM foo, bar;
foo.id | foo.name | bar.id | bar.text
-------+----------+--------+---------
...

...rather than:

SELECT * FROM foo, bar;
id | name | id | text
---+------+----+-----
...

You'd have to use aliases, like

SELECT id AS "foo.id" ...

Yours,
Laurenz Albe

#3Jasen Betts
jasen@xnet.co.nz
In reply to: Andrew Klaassen (#1)
Re: table.column in query results?

On 2009-07-22, Andrew Klaassen <clawsoon@yahoo.com> wrote:

Hi,

Is it possible to get table.column in query results rather than just column?

it is possible to get the OID of the table from libpq.
I don't think psql provides display of the table name as a
formatting option, and most wrapper around libpq seem to
ignore this feature.

if you can manipulate the query you can alias the column in
the query and hope that none of the tables or columns has a
dot in its name already!

#4Andrew Klaassen
clawsoon@yahoo.com
In reply to: Jasen Betts (#3)
Re: table.column in query results?
--- On Thu, 7/23/09, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:

Andrew Klaassen wrote:

Is it possible to get table.column in query results

rather

than just column?

I.e. I'd like:

SELECT * FROM foo, bar;
foo.id | foo.name | bar.id | bar.text
-------+----------+--------+---------
...

...rather than:

SELECT * FROM foo, bar;
id | name | id | text
---+------+----+-----
...

You'd have to use aliases, like

SELECT id AS "foo.id" ...

Ah... so no way to do it with a wildcard in the query?

That's unfortunate.

Thanks.

Andrew

__________________________________________________________________
The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/