Is there a way to replace select * fields in result ?

Поиск
Список
Период
Сортировка
Искать

Is there a way to replace select * fields in result ?

От:
Condor <condor@stz-bg.com>
Дата:

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


Re: Is there a way to replace select * fields in result ?

От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:

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.

Re: Is there a way to replace select * fields in result ?

От:
Condor <condor@stz-bg.com>
Дата:
On 12-06-2021 11:13, David G. Johnston wrote:
> On Saturday, June 12, 2021, Condor  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,


Re: Is there a way to replace select * fields in result ?

От:
Alban Hertroys <haramrae@gmail.com>
Дата:


> On 12 Jun 2021, at 10:00, Condor  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.






FAQ