[postgis-users] Except

George Pavlov gpavlov at mynewplace.com
Wed Nov 28 06:05:07 PST 2007


this is a pure SQL question, not a postGIS one really. there is nothing like that in the SQL standard but you can come up with a generic SQL-generating code using the system tables. something along these lines (using psql as an example):

test=# \t
Showing only tuples.
test=# \a
Output format is unaligned.
test=# \o /tmp/test.sql
test=# select 
test-#   'select ' || 
test-#   array_to_string(array(
test-#     select column_name::text from information_schema.columns c
test-#     where c.table_name = t.table_name
test-#       and column_name!='employee_id'
test-#   ),', ') ||
test-#   ' from ' || table_name
test-# from information_schema.tables t
test-# where table_schema = 'test' and table_name = 'employee';
test=# \o
test=# \i /tmp/test.sql
...

you get the idea. hope this helps.

george


-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net on behalf of Matt Doughty
Sent: Wed 11/28/07 04:31 AM
To: PostGIS Users Discussion
Subject: [postgis-users] Except
 
Hi,

Is there a way of selecting all fields except one in particular? I'd
like to create a query that says something like: select * except
field01.  The thing is the query needs to be valid for a number of
different tables, each with a different set of fields apart from one
(gid), which I don't want to select.

Cheers,

Matt



Matt Doughty

GEOGRAMA S.L.
Tel.:  +34 945 13 13 72    652 77 14 15
Fax: +34 945 23 03 40 
www.geograma.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20071128/dde86407/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 3743 bytes
Desc: image001.jpg
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20071128/dde86407/attachment.jpg>


More information about the postgis-users mailing list