Problem in mysql_query Insert with On Duplicate key

Hi…

Before I have no problem in using On Duplicate Key, but now i have because of using time function.

Before I only have insert query:


$result = mysql_query("INSERT INTO regular_sum_hours(EMP_NO, Hours) SELECT EMP_NO, sec_to_time(SUM(time_to_sec(Rendered))) FROM regular_dtr_total GROUP BY EMP_NO") or die(mysql_error());    

And now I think that I need to add a syntax for Update, so i revise my code:


$result = mysql_query("INSERT INTO regular_sum_hours(EMP_NO, Hours) SELECT EMP_NO, sec_to_time(SUM(time_to_sec(Rendered))) FROM regular_dtr_total GROUP BY EMP_NO ON DUPLICATE KEY EMP_NO = EMP_NO, Hours = sec_to_time(SUM(time_to_sec(Rendered)))") or die(mysql_error());

and I got a problem in this part:

Hours = sec_to_time(SUM(time_to_sec(Rendered)))")

Thank you

no, you don’t

you got a problem in this part here –

ON DUPLICATE KEY EMP_NO = EMP_NO,

did you test this query outside of php before trying to incorporate it into your php code?

if you had done so, i’m betting you would have got a more informative error message