Skip to content
Advertisement

MySQL Update inner Join with MAX Date

In MYSQL 8.0 I have two tables with following structure:

I am trying to update a value of EnromentStatus in child table by joining in on Enrolment table using the TSQL below:

Problem is Enrolment has multiple entries for the child enrolment so I need to do MAX(DateUpdated) to get just a single record to update the status to latest status but I can’t wrap my head around to just get one record.

Advertisement

Answer

Try something like this,
It’s just a simple nested query that updates all of the child’s statuses in one go without using INNER JOIN.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement