I want to save the weekly logon times of the students in the table logon_times_20BECW.
This table just has columns id, studentnr, Week1 to Week19
I get the logon times from the table allstudents20BE
But I only want to UPDATE the table logon_times_20BECW IF the field is zero.
To start with, all fields are zero. The query below works.
UPDATE logon_times_20BECW, allstudents20BE SET logon_times_20BECW.Week2=IF(logon_times_20BECW.Week2=0,allstudents20BE.logon_time, logon_times_20BECW.Week2) WHERE logon_times_20BECW.studentnr = 2025010101
This query works, but when the value of the field is not zero, I get an error. I don’t know how to avoid that.
Error:
#1292 - Truncated incorrect DOUBLE value: ‘2022-02-16 10:48:48’