pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Is there a way to replace select * fields in result ?
4+ messages / 3 participants
[nested] [flat]

* Is there a way to replace select * fields in result ?
@ 2021-06-12 08:00  Condor <condor@stz-bg.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Condor @ 2021-06-12 08:00 UTC (permalink / raw)
  To: pgsql-general <pgsql-general@lists.postgresql.org>


Hello,

Is there a way to replace select * fileds in result ?
I have select qw.* from table but I want field for example mm to be 
replaced with custom value like:

select qw.*, case whem length(qw.mm) > 0 THEN COALESCE(SUBSTRING(qw.mm, 
1, 1), '') ELSE qw.mm END AS qw.mm

Is there some way to do that ?

Regards,
HS





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Is there a way to replace select * fields in result ?
@ 2021-06-12 08:13  David G. Johnston <david.g.johnston@gmail.com>
  parent: Condor <condor@stz-bg.com>
  1 sibling, 1 reply; 4+ messages in thread

From: David G. Johnston @ 2021-06-12 08:13 UTC (permalink / raw)
  To: Condor <condor@stz-bg.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>

On Saturday, June 12, 2021, Condor <condor@stz-bg.com> wrote:

>
> Hello,
>
> Is there a way to replace select * fileds in result ?
> I have select qw.* from table but I want field for example mm to be
> replaced with custom value like:
>
> select qw.*, case whem length(qw.mm) > 0 THEN COALESCE(SUBSTRING(qw.mm,
> 1, 1), '') ELSE qw.mm END AS qw.mm
>
> Is there some way to do that ?
>
>
No.  If you don’t want a column from “*” to appear in the output you cannot
use “*”.  In general, for production, you should avoid “*” anyway.

David J.

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Is there a way to replace select * fields in result ?
@ 2021-06-12 08:18  Condor <condor@stz-bg.com>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Condor @ 2021-06-12 08:18 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>

On 12-06-2021 11:13, David G. Johnston wrote:
> On Saturday, June 12, 2021, Condor <condor@stz-bg.com> wrote:
> 
>> 
>> Hello,
>> 
>> Is there a way to replace select * fileds in result ?
>> I have select qw.* from table but I want field for example mm to be
>> replaced with custom value like:
>> 
>> select qw.*, case whem length(qw.mm) > 0 THEN 
>> COALESCE(SUBSTRING(qw.mm,
>> 1, 1), '') ELSE qw.mm END AS qw.mm
>> 
>> Is there some way to do that ?
>> 
>> 
> No.  If you don’t want a column from “*” to appear in the output you 
> cannot
> use “*”.  In general, for production, you should avoid “*” anyway.
> 
> David J.

Uh .. yes I know. I trying to revisit old procedures from team that left 
the project ... and it's seems they use select * to a lot of places.

Thanks,





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Is there a way to replace select * fields in result ?
@ 2021-06-12 09:15  Alban Hertroys <haramrae@gmail.com>
  parent: Condor <condor@stz-bg.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Alban Hertroys @ 2021-06-12 09:15 UTC (permalink / raw)
  To: Condor <condor@stz-bg.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>



> On 12 Jun 2021, at 10:00, Condor <condor@stz-bg.com> wrote:
> 
> select qw.*, case whem length(qw.mm) > 0 THEN COALESCE(SUBSTRING(qw.mm, 1, 1), '') ELSE qw.mm END AS qw.mm

A little off-topic, but isn’t that a roundabout way of writing just this?:

	select qw.*, coalesce(substring(qw.mm, 1, 1), '') as mm

Or even:

	select qw.*, coalesce(left(qw.mm, 1), '') as mm


Regards,

Alban Hertroys
--
There is always an exception to always.









^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2021-06-12 09:15 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-12 08:00 Is there a way to replace select * fields in result ? Condor <condor@stz-bg.com>
2021-06-12 08:13 ` David G. Johnston <david.g.johnston@gmail.com>
2021-06-12 08:18   ` Condor <condor@stz-bg.com>
2021-06-12 09:15 ` Alban Hertroys <haramrae@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox