joining on concatonation?

From: "blackwater dev" <blackwaterdev(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: joining on concatonation?
Date: 2008-02-22 20:05:52
Message-ID: 34a9824e0802221205m1a50f170xc9b84b36e4de95d0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a query that is driving me nuts. In one table we have data that is
split between two columns and I'm trying to pull in all values from another
table where that column is represented by one piece of data. Also, all the
info in column2 is unique but not in col 1.

table1

col1_pfx
col2_number
col3

Table2
col1
col3

update table1 set col3=(select col3 from table2 where table2.col1=(
table1.col1_pfx || table1.col2_number));

I've tried using a join and all other methods and nothing seems to work.
Table2 has a primary key on col1 yet when I do explain posgres still seems
to do a sqential scan on that column.

Any thoughts?

Thanks!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Douglas McNaught 2008-02-22 20:37:15 Re: Understanding ps -ef "command" column
Previous Message Tomasz Ostrowski 2008-02-22 19:59:08 Re: Selecting large objects stored as bytea