Re: SQL UPDATE question

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL UPDATE question
Date: 2008-03-14 18:44:30
Message-ID: 20080314184430.GB6979@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

am Fri, dem 14.03.2008, um 13:30:02 -0500 mailte Joshua folgendes:
> Hi,
> Here is a quick and easy one I have a questions about:
>
> I have a table (customers) that has a field (firstname) with the
> following data.
>
> firstname
> --------------------
> Mike H
> Josh
> Jim B
> Katie I
> Jeff
> Suzy
> John R
>
>
> Can someone provide the syntax for a SQL UPDATE statement that will
> remove middle initial in the above column and leave the first name intact?

A little hint, i hopen it is helpful for you:

test=*# select regexp_replace('Mike H', ' .*$','');
regexp_replace
----------------
Mike

You can use this regexp_replace() - function in your UPDATE-Command.
Attention: i assume, that there are no space before the first name.

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Justin 2008-03-14 18:45:47 Re: pgbench not setting scale size correctly?
Previous Message Erik Jones 2008-03-14 18:41:55 Re: SQL UPDATE question