Setting a field value when multiple records exist

Hi Everyone,

I have a question on how to set a field value in multiple records where there is a specific key, when a  condition is meet within multiple records.

I have a table 'A', it contains 4 fields:
TEAM_NAME
PLAYER_NAME
PLAYER_STATUS
TEAM_STATUS

I will have multiple records with the same TEAM_NAME(key). I want to set the TEAM_STATUS to 'Y' in each team record, only when ALL of the individual PLAYER_STATUS for that team is 'Y'.

Thanks in advance.

Mark
Mark1MAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

momi_sabagCommented:
update your_table t1
set team_status = 'Y'
where not exists (select 1 from your_table t2 where t1.team_name = t2.team_name and player_status != 'Y')
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mustaccioCommented:
momi_sabag's answer is appropriate for your current table definition, but generally speaking your data model does not seem adequate for the requirements. You clearly have two entities: team and player, which asks for at least two separate tables.
0
Mark1MAuthor Commented:
momi_sabag & mustaccio,

Thank you very much for your responses.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DB2

From novice to tech pro — start learning today.