Re: [SQL] Substitute a Character
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 ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings
[SQL] Substitute a Character
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
Re: [SQL] Substitute a Character
Judith [EMAIL PROTECTED] 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° ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster
Re: [SQL] Substitute a Character
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 ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
Re: [SQL] Substitute a Character
On 9/6/06 12:53 PM, Judith [EMAIL PROTECTED] 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²; ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match