pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Substitute a Character
5+ messages / 5 participants
[nested] [flat]

* Substitute a Character
@ 2006-09-06 16:53 Judith <jaltamirano@correolux.com.mx>
  2006-09-06 17:09 ` Re: Substitute a Character Andreas Kretschmer <akretschmer@spamfence.net>
  2006-09-06 17:14 ` Re: Substitute a Character Chris Mair <chrisnospam@1006.org>
  2006-09-06 20:20 ` Re: Substitute a Character Daryl Richter <daryl@eddl.us>
  2006-09-07 09:03 ` Re: Substitute a Character Kaloyan Iliev <news1@faith.digsys.bg>
  0 siblings, 4 replies; 5+ messages in thread

From: Judith @ 2006-09-06 16:53 UTC (permalink / raw)
  To: pgsql-sql

    Hello everybody!!  
   
    I have a field type text with folios like this: A98526

    but I want to change de A for a 0 like this: 098526, exists a way to 
do this in a query???

    Thanks in advanced!!!





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

* Re: Substitute a Character
  2006-09-06 16:53 Substitute a Character Judith <jaltamirano@correolux.com.mx>
@ 2006-09-06 17:09 ` Andreas Kretschmer <akretschmer@spamfence.net>
  3 siblings, 0 replies; 5+ messages in thread

From: Andreas Kretschmer @ 2006-09-06 17:09 UTC (permalink / raw)
  To: pgsql-sql

Judith <jaltamirano@correolux.com.mx> schrieb:

>     Hello everybody!!       I have a field type text with folios like this: 
> A98526
> 
>     but I want to change de A for a 0 like this: 098526, exists a way to do 
> this in a query???

Perhaps something like this:

test=# select regexp_replace('A98526', '^.', '0');
 regexp_replace
----------------
 098526
(1 row)

http://www.postgresql.org/docs/8.1/interactive/functions-matching.html#FUNCTIONS-POSIX-REGEXP


Andreas
-- 
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."    (unknow)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°



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

* Re: Substitute a Character
  2006-09-06 16:53 Substitute a Character Judith <jaltamirano@correolux.com.mx>
@ 2006-09-06 17:14 ` Chris Mair <chrisnospam@1006.org>
  3 siblings, 0 replies; 5+ messages in thread

From: Chris Mair @ 2006-09-06 17:14 UTC (permalink / raw)
  To: Judith <jaltamirano@correolux.com.mx>; +Cc: pgsql-sql


>     Hello everybody!!  
>    
>     I have a field type text with folios like this: A98526
> 
>     but I want to change de A for a 0 like this: 098526, exists a way to 
> do this in a query???
> 
>     Thanks in advanced!!!

You should look at these functions:
http://www.postgresql.org/docs/8.1/static/functions-string.html

This for example might work for you:
select translate('A98526', 'A', '0');

Bye, Chris.


-- 

Chris Mair
http://www.1006.org




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

* Re: Substitute a Character
  2006-09-06 16:53 Substitute a Character Judith <jaltamirano@correolux.com.mx>
@ 2006-09-06 20:20 ` Daryl Richter <daryl@eddl.us>
  3 siblings, 0 replies; 5+ messages in thread

From: Daryl Richter @ 2006-09-06 20:20 UTC (permalink / raw)
  To: Judith <jaltamirano@correolux.com.mx>; pgsql-sql

On 9/6/06 12:53 PM, "Judith" <jaltamirano@correolux.com.mx> wrote:

>     Hello everybody!!
>    
>     I have a field type text with folios like this: A98526
> 
>     but I want to change de A for a 0 like this: 098526, exists a way to
> do this in a query???

select translate( 'A98526', 'A', '0' );

translate    
 ------------ 
 098526       

 1 record(s) selected [Fetch MetaData: 1/ms] [Fetch Data: 0/ms]

 [Executed: 9/6/06 4:18:44 PM EDT ] [Execution: 99/ms]

> 
>     Thanks in advanced!!!
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend

--
Daryl
Email *my = [ daryl at: @"eddl" dot: @"us" ];
Weblog *blog = @²http://itsallsemantics.com²;







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

* Re: Substitute a Character
  2006-09-06 16:53 Substitute a Character Judith <jaltamirano@correolux.com.mx>
@ 2006-09-07 09:03 ` Kaloyan Iliev <news1@faith.digsys.bg>
  3 siblings, 0 replies; 5+ messages in thread

From: Kaloyan Iliev @ 2006-09-07 09:03 UTC (permalink / raw)
  To: Judith <jaltamirano@correolux.com.mx>; pgsql-sql

Hi,

Try:
UPDATE foe SET field = regexp_replace(field, '^.', '0');
OR
UPDATE foe SET field = regexp_replace(field, 'A', '0');

This will replace in table "foe" in the column "field" 'A' with '0';

Regards,
  Kaloyan Iliev

Judith wrote:

>    Hello everybody!!       I have a field type text with folios like 
> this: A98526
>
>    but I want to change de A for a 0 like this: 098526, exists a way 
> to do this in a query???
>
>    Thanks in advanced!!!
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
>




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


end of thread, other threads:[~2006-09-07 09:03 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-09-06 16:53 Substitute a Character Judith <jaltamirano@correolux.com.mx>
2006-09-06 17:09 ` Andreas Kretschmer <akretschmer@spamfence.net>
2006-09-06 17:14 ` Chris Mair <chrisnospam@1006.org>
2006-09-06 20:20 ` Daryl Richter <daryl@eddl.us>
2006-09-07 09:03 ` Kaloyan Iliev <news1@faith.digsys.bg>

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