Re: [GENERAL] Populate Table From Two Other Tables

2012-06-05 Thread Darren Duncan
Rich Shepard wrote: I'm surprised: that worked! I thought the WHERE clause was looking for equivalency, not an assignment. SQL generally uses "=" to mean equality test, but sometimes it also uses "=" to mean assignment; it depends on the context; eg, in an UPDATE statement it can have both

Re: [GENERAL] Populate Table From Two Other Tables

2012-06-05 Thread Adrian Klaver
On 06/05/2012 04:49 PM, Rich Shepard wrote: On Tue, 5 Jun 2012, David Johnston wrote: As for the duplicate key I would first check to see if you are inserting into a non-empty table and that one or more of your newly inserted records conflicts with existing records on the waterchem table. The e

Re: [GENERAL] Populate Table From Two Other Tables

2012-06-05 Thread Rich Shepard
On Tue, 5 Jun 2012, David Johnston wrote: As for the duplicate key I would first check to see if you are inserting into a non-empty table and that one or more of your newly inserted records conflicts with existing records on the waterchem table. The easiest way would be to insert into a staging

Re: [GENERAL] Populate Table From Two Other Tables

2012-06-05 Thread David Johnston
records are returned. David J. > -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of Rich Shepard > Sent: Tuesday, June 05, 2012 7:28 PM > To: pgsql-general@postgresql.org > Subject: Re: [GENERAL] Populate Table Fro

Re: [GENERAL] Populate Table From Two Other Tables

2012-06-05 Thread Rich Shepard
On Tue, 5 Jun 2012, Greg Williamson wrote: Try a single equals sign, e.g. WHERE c.site = s.siteid Greg, I'm surprised: that worked! I thought the WHERE clause was looking for equivalency, not an assignment. There's another problem now that will be more difficult to fix. Postgres tells me

Re: [GENERAL] Populate Table From Two Other Tables

2012-06-05 Thread Greg Williamson
Rich -- >  I want to combine columns in two tables and use the exported resulting >table for statistical analyses. The SQL script is: > >INSERT INTO waterchem (site, sampdate, param, quant, ceneq1, low, high, >   stream, basin) >   SELECT c.site, c.sampdate, c.param, c.quant, c.ceneq1, c.low, c.