From: | Christoph Haller <ch(at)rodos(dot)fzk(dot)de> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Cc: | mallah(at)trade-india(dot)com |
Subject: | Re: getting rid of "Adding missing FROM-clause entry...." |
Date: | 2003-04-17 13:20:59 |
Message-ID: | 3E9EAA3B.DAAE2E86@rodos.fzk.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
>
> Actually i have to update multiple columns my original
> query was:
>
> UPDATE profile_master SET
>
> title1=a.title1 , fname1=a.fname1 , mname1=a.mname1 ,
> lname1=a.lname1 , desg1 = a.desg1 FROM
>
> (
> SELECT company_id , titile as title1 ,fname as fname1 ,mname as
mname1 ,
> lname as lname1 ,company_position as desg1 from
public.catalog_key_contacts as b
> where b.company_id=profile_master.company_id order by contact_id
limit 1 offset 0)
>
> as a WHERE
>
> profile_master.source='CATALOG' ;
>
> > Hi I am having problem with an UPDATE ... FROM
> > SQL where the FROM table is a subquery.
> >
> > UPDATE profile_master set title1=a.title1 FROM
> > (
> >
> > SELECT company_id , titile as title1 ,fname as fname1 ,mname as
mname1
> > ,lname as lname1 ,company_position as desg1 from
> > public.catalog_key_contacts where
company_id=profile_master.company_id
> > order by contact_id limit 1 offset 0 ) as a
> > where profile_master.source='CATALOG' ;
> > NOTICE: Adding missing FROM-clause entry in subquery for table
> > "profile_master" UPDATE 711
> >
> > its showing an update of 711 however all the 711 matching rows are
getting
> > updated to the same value.
> >
> > can anyone tell me how to write this query properly ?
> >
I think you need a second reference to the profile_master table.
And why are you using "limit 1 offset 0"?
So I'd say
UPDATE profile_master SET
title1=a.title1 , fname1=a.fname1 , mname1=a.mname1 ,
lname1=a.lname1 , desg1 = a.desg1 FROM
(
SELECT company_id , title as title1 ,fname as fname1 ,mname as mname1
,
lname as lname1 ,company_position as desg1
from public.catalog_key_contacts as b ,profile_master as c
where b.company_id=c.company_id order by contact_id )
as a WHERE
source='CATALOG' ;
Does this work?
Regards, Christoph
From | Date | Subject | |
---|---|---|---|
Next Message | Rajesh Kumar Mallah | 2003-04-17 13:45:43 | Re: getting rid of "Adding missing FROM-clause entry...." |
Previous Message | Rajesh Kumar Mallah | 2003-04-17 12:18:29 | Re: getting rid of "Adding missing FROM-clause entry...." |