I have a quite nested mysql query and would like to insert or update values based an on a select statement.
The following code is simplified however demonstrates the