Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to run a query that looks like this:

$DB->query("INSERT INTO table (
  SELECT s.value1, s.value2, s.value3, t.value1, u.value1, u.value2, u.value3, u.value4
  FROM aTable AS s
  LEFT JOIN aTable2 AS u ON u.uID = s.uid 
  WHERE u.spent < ". $needed ."
  GROUP BY s.uid, s.fid ) 
  ON DUPLICATE KEY UPDATE
  value1 = VALUES(u.value1), 
  value2 = VALUES(u.value2), 
  value3 = VALUES(u.value3), 
  value4 = VALUES(u.value4);
");


However this returns the error:

Unknown column 'u.value1' in 'field list'

Please note that this is the first time I'm working with MySQL at this level, so I have no idea how the DUPLICATE KEY UPDATE function works...

What i intent to do with the table is like a cache, because the infromation is fetched from some very large table
Posted
Updated 17-Aug-13 10:34am
v2
Comments
Member 10215641 17-Aug-13 16:25pm    
Any help you can give is would be so nice, because im must be hornest, ive never been this deep in mysql before
Bernhard Hiller 19-Aug-13 4:04am    
Does the table Atble2 have a column with the column name of "value1"?
And: Table/Alias t is missing.
Try to get the inner SELECT query correct as a first step.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900