From: | John Tuliao <jptuliao(at)htechcorp(dot)net> |
---|---|
To: | "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Query question |
Date: | 2012-01-26 12:00:37 |
Message-ID: | 4F214065.8080201@htechcorp.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I seem to have a problem with a specific query:
The inside query seems to work on it's own:
select prefix
from john_prefix
where strpos(jpt_test.number,john_prefix.prefix) = '1'
order by char_length(john_prefix.prefix) desc limit 1
but when I execute it with this:
UPDATE
jpt_test
set
number = substring(number from length(john_prefix.prefix)+1)
from
john_prefix
where
prefix in (
select prefix
from john_prefix
where strpos(jpt_test.number,john_prefix.prefix) = '1'
order by char_length(john_prefix.prefix) desc limit 1
) ;
table contents are as follows
john_prefix table:
prefix
---------
123
234
jpt_test table:
number
-----------
1237999999
0234999999 <<< supposed to have no match
2349999999
Am I missing something here? Any help will be appreciated.
Regards,
JPT
From | Date | Subject | |
---|---|---|---|
Next Message | Carlos Mennens | 2012-01-26 23:59:04 | Update Mass Data in Field? |
Previous Message | ktm@rice.edu | 2012-01-25 14:31:49 | Re: Problem with sequence increment |