How would I do this in SQL?
Posted
by bergyman
on Stack Overflow
See other posts from Stack Overflow
or by bergyman
Published on 2010-04-14T23:45:09Z
Indexed on
2010/04/14
23:53 UTC
Read the original article
Hit count: 533
sql
Let's say I have the following tables:
PartyRelationship
EffectiveDatedAttributes
PartyRelationship contains a varchar column called class.
EffectiveDatedAttributes contains a foreign key to PartyRelationship called ProductAuthorization.
If I run this:
select unique
eda.productauthorization
from
effectivedatedattributes eda
inner join
partyrelationship pr
on
eda.productauthorization = pr.ID
where
pr.class = 'com.pmc.model.bind.ProductAuthorization'
it returns a list of ProductAuthorization IDs. I need to take this list of IDs and insert a new row into EffectiveDatedAttributes for every ID, containing the ID as well as some other data. How would I iterate over the returned IDs from the previous select statement in order to do this?
© Stack Overflow or respective owner