Issue in saving 0000-00-00 00:00:00 or IsNull values
I notice that in my query:
it did not insert data where LOGOUT is 0000-00-00 00:00:00
$result = mysql_query("INSERT INTO payroll.reg_att(EMP_NO, LOGIN, LOGOUT, TotalHours)
SELECT DISTINCT a.EMP_NO, a.LOGIN, a.LOGOUT, TIMEDIFF(a.LOGOUT, a.LOGIN) FROM payroll.date_upload d, attendance.employee_attendance a JOIN hris.employment em ON (a.EMP_NO = em.EMP_NO AND em.STATUS = 'Reg Operatives') WHERE DATE(LOGOUT) BETWEEN '$FROM_DATE' AND '$TO_DATE' AND d.EMP_STATUS = 'Reg Operatives' OR ISNULL(LOGIN) OR ISNULL(LOGOUT)")
Hi, to begin, can you represent your thought out logical precedences for the "ands" and "ors" in the Query using parentheses?
Originally Posted by WyCnet
Use parenthesis in OR and And?
Now, I realize why the LOGOUT = 0000-00-00 00:00:00 was not save because of this condition:
now how can I get even the DATE(LOGOUT) = 0000-00-00
$FROM_DATE = 2012-03-01
$TO_DATE = 2012-03-15
WHERE DATE(LOGOUT) BETWEEN '$FROM_DATE' AND '$TO_DATE'
Thank you so much
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)