| From: | Sam Mason <sam(at)samason(dot)me(dot)uk> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Join three fields into one on same table |
| Date: | 2008-05-20 00:04:30 |
| Message-ID: | 20080520000430.GF27988@frubble.xen.chris-lamb.co.uk |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Mon, May 19, 2008 at 03:36:39PM -0600, Scott Marlowe wrote:
> On Mon, May 19, 2008 at 4:51 AM, jrivero <godsea(at)gmail(dot)com> wrote:
> > My problem is not that make update query.
> >
> >> update table set date=(select year || '-' || month || '-' || day || ' 01:00:00' as newdate from table)
>
> Cast the output of those concatenations to date:
>
> update table set date=(select (year || '-' || month || '-' || day || '
> 01:00:00')::date as newdate from table)
I'd guess the OP doesn't want the sub-query, if he posted the error
message we'd know for sure. I'd guess something like:
update table set date=(year||'-'||month||'-'||day||'01:00:00')::date;
If the "date" column really is of date type, then the final
"||'01:00:00'" is somewhat superfluous.
Sam
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dan Joo | 2008-05-20 00:18:49 | psql: FATAL: Ident authentication failed for user "postgres" |
| Previous Message | Dragan Zubac | 2008-05-19 23:44:26 | Re: Vacuuming on heavily changed databases |