Update TABLE from a Related Table with Multiple Entries (only wanting the latest val)
The example below is not real, but if I can solve this, I know I can solve the bigger problem I have!
Using MYSQL, I have two tables. Farm and Animals. Animals can have several items connected to farm with the "farmid" serving as a related key.
What I need to do is run an update query, that automatically populates "farm.latestestanimal" with the "animalname" from the latest entry of Animals that is connected to the farm.
I know this sample below is wrong, but it might show what I am trying to do:
"UPDATE farm SET farm.latestanimal = animals.animalname WHERE animal.farmid = farm.id ORDER BY animal.dateadded DESC LIMIT 1"
Can someone point me in the right direction to making this work?