Skip site navigation (1) Skip section navigation (2)

Re: Update entire column with new date values

From: Richard Huxton <dev(at)archonet(dot)com>
To: "Weiss, Kevin" <kevin(dot)weiss(at)selkirkinc(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Update entire column with new date values
Date: 2006-07-27 15:45:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Weiss, Kevin wrote:
> I need to update the date for each file (the "date" & "filename"
> columns). However, the updated values for date are not the same for each
> file (due to when the files were last modified). I can import the new
> date values from a text file containing the date and filename. 
> What sort of "UPDATE" command do I use in this case? Essentially, I'm
> trying to do something like:
> UPDATE docs SET date = '{$input_date}'
>     FROM ('C:/Temp/docupdate.txt')
>     WHERE filename = '{$input_filename}';

You'll want to gather your updates into a table and then use the 
non-standard FROM clause to do pretty much what you're trying to here.

UPDATE docs SET date = ???
FROM newvals
WHERE docs.filename=newvals.filename

Failing that look at a subselect in your SET clause.

   Richard Huxton
   Archonet Ltd

In response to

pgsql-general by date

Next:From: Richard HuxtonDate: 2006-07-27 15:50:20
Subject: Re: Permissions to connect to postgres database
Previous:From: Merlin MoncureDate: 2006-07-27 15:44:43
Subject: Re: PostgreSQL and Windows 2003 DFS Replication

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group