I am going update table_a with variable stored in table_b. but when i trying update with select query, i got errors, please help me. Thank you alot.
This is struct of 2 tables:
CREATE TABLE IF NOT EXISTS `table_a` (
  `fk1` int(11) DEFAULT NULL,
  `avg_100` int(11) DEFAULT NULL,
  `avg_score` int(11) DEFAULT NULL,
  `cvg_date` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `table_b` (
  `fk1` int(11) NOT NULL DEFAULT '0',
  `avg_100` int(11) DEFAULT NULL,
  `avg_score` int(11) DEFAULT NULL,
  `cvg_date` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
and when i try execute query
UPDATE table_a a LEFT JOIN (( 
        SELECT fk1, SUM(avg_100) as avg_100, SUM(avg_score) as avg_score, MAX(cvg_date) as cvg_date
        FROM table_b
            GROUP BY fk1 
 ) AS b1 ) AS b ON a.fk1= b.fk1
SET
    a.avg_score = b.avg_score,
  a.avg_100 = b.avg_100, 
  a.cvg_date = b.cvg_date
i got a error:
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'b ON a.fk1= b.fk1
SET
    a.avg_score = b.avg_score,
  a.avg_100 = b.avg_100, 
' at line 4
 
     
     
     
    