From: | Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com> |
---|---|
To: | Rafal Pietrak <rafal(at)ztk-rp(dot)eu>, Dane Foster <studdugie(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: partial JOIN (was: ID column naming convention) |
Date: | 2015-10-26 00:49:19 |
Message-ID: | 562D788F.4000001@BlueTreble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 10/25/15 2:30 AM, Rafal Pietrak wrote:
> So personally, I don't see a star in a select list so harmfull, quite
> the oposit.
Using * outside the database is generally very dangerous. Using it
*inside* the database can be very useful, because frequently it's
exactly what you want (give me all the columns, dammit!). In particular,
I find it useful in views where I want the original data, along with
some calculated or other values. For example,
SELECT nspname, c.oid, * FROM pg_class c LEFT JOIN pg_namespace ON...
But there's also times I've wanted a way to manipulate what * would
normally do. In particular, *_except_for(field_list), and *_replace(
regexp_replace to run on each field name). If those existed (and maybe a
way to combine them), it wouldn't be terribly hard for you do handle
your sled query with something like:
SELECT s.*, l.*( s/.*/left_%/ ), r.*( s/.*/right_& )
FROM sled s JOIN runner l ON ... JOIN runner r ON ...
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
From | Date | Subject | |
---|---|---|---|
Next Message | Jim Nasby | 2015-10-26 00:54:55 | Re: Duplicate rows during pg_dump |
Previous Message | Bill Moran | 2015-10-25 23:11:40 | I'm starting a PostgreSQL user's group in Pittsburgh |