I'm trying to run an INSERT statement (it's really an update though) using the results of a SELECT statement and am getting error 1592.

The problem with this is threefold:
  1. I'm not using Replication.
  2. I have no plans to use Replication at a later date/stage.
  3. I've already filtered/limited the SELECT statement's results in a way that should eliminate the issue.


Granted, #3 is really the only point of import since it's just good practice...

ANYWAY

PHP Code:
INSERT INTO 
    
`mining2`.`coin_values

(
    
SELECT 
        
`mcv`.`coin_id`, 
        `
mcv`.`timestamp`, 
        `
mcv`.`value

    
FROM 
        
`mining2`.`coin_values` AS `mcv
        
INNER JOIN 
            
`mining2`.`coins` AS `mc
        
ON 
            
`mcv`.`coin_id` = `mc`.`id

    
WHERE 
        NOT 
`mc`.`abbr`='BTC' AND 
        `
mcv`.`timestamp`=(
            
SELECT 
                MAX
(`mcvs_i`.`timestamp`) 

            
FROM 
                
`mining2`.`coin_values_snapshots` AS `mcvs_i

            
WHERE 
                
`mcvs_i`.`coin_id`=`mcv`.`coin_id`

            
ORDER BY 
                
`mcvs_i`.`timestampDESC
        


    
GROUP BY 
        
`mcv`.`coin_id`
)

ON DUPLICATE KEY UPDATE 
    
`value`=VALUES(`value`), 
    `
timestamp`=VALUES(`timestamp`) 


I'm certain the issue is with "`mcv`.`timestamp`=(SELECT..." but I don't know of a better way to handle this since I don't know the specific timestamp (it changes each time) OR the specific number of unique coin_ids (It can change as my pool adds more to the mix - old coins aren't removed from the DB at this time).