SQL question

pfd

Reputable Poster
I have a case where I want to update a field in F03012(Customer Master) if the F0101 search type is CB and if the country in F0116 =US for that address book record. I know how to update based on a join of 2 tables but not sure how to do it with three tables.

I tried it with a statement like this but it does not work.

select * from pydta/f03012 a where exists (select * from
pydta/f0101 b where b.aban8=a.aian8 and b.abmcu in
(' 123456',' 234567') and b.abat1 in ('CS','CB'))
where exists (select * from pyindta/f0116 c where c.alan8=aian8 and
c.alctr = 'US')

Any help would be appreciated.

Thanks,
Matt
 
Hi pfd,

The correct SQL should be as below:

select * from pydta/f03012 where aian8 in (select aban8 from pydta/f0101 where abmcu in
(' 123456',' 234567') and abat1 in ('CS','CB'))
and aian8 in (select alan8 from pyindta/f0116
where alctr = 'US')

Hope it helps you.

Regards!
 
Back
Top