Re: Populate Table From Two Other Tables

From: Greg Williamson <gwilliamson39(at)yahoo(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Populate Table From Two Other Tables
Date: 2012-06-05 23:02:28
Message-ID: 1338937348.45524.YahooMailNeo@web46103.mail.sp1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.high,
>     s.stream, s.basin
>   FROM chemistry as c, sites as s
>     WHERE c.site == s.siteid;
>

Try a single equals sign, e.g. WHERE c.site = s.siteid

>  The problem is that both c.site and s.siteid are of type VARCHAR(16) and
>postgres tells me,
>
>ERROR:  operator does not exist: character varying == character varying
>
>and provides the hint to add explicit type casts. Since the string length of
>site/siteid varies I don't see how to cast both to a working type.
>
>  Please suggest how I can populate this table while avoiding the operator
>error.
>
HTH,

Greg Williamson

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kraus Philipp 2012-06-05 23:15:36 acessibility for tables
Previous Message Rich Shepard 2012-06-05 22:50:47 Populate Table From Two Other Tables