From: | Erik Jones <erik(at)myemma(dot)com> |
---|---|
To: | joshua(at)joshuaneil(dot)com |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: SQL UPDATE question |
Date: | 2008-03-14 18:41:55 |
Message-ID: | 9A82FF44-1E99-4E94-8D73-33ADC7165138@myemma.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mar 14, 2008, at 1:30 PM, Joshua wrote:
> 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?
-- notice there is a space before the .* in the regex
UPDATE table
SET firstname = regexp_replace(firstname, ' .*', '');
Erik Jones
DBA | Emma®
erik(at)myemma(dot)com
800.595.4401 or 615.292.5888
615.292.0777 (fax)
Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2008-03-14 18:44:30 | Re: SQL UPDATE question |
Previous Message | Joshua | 2008-03-14 18:30:02 | SQL UPDATE question |