SELECT tbl_varsity_2.idnumber AS IDNUMBER, CONCAT(tbl_varsity_2.firstname, ' ', tbl_varsity_2.middlename, '. ', tbl_varsity_2.lastname) AS NAME,
COALESCE(tbl_attendance_2.login, { d '0000-00-00 00:00:00' }) AS LOGIN, COALESCE(tbl_attendance_2.logout, { d '0000-00-00 00:00:00' }) AS LOGOUT,
tbl_attendance_2.totaltime AS TOTALTIME, tbl_varsity_2.sport AS SPORT FROM tbl_varsity tbl_varsity_2 LEFT JOIN
tbl_attendance tbl_attendance_2 ON tbl_varsity_2.idnumber = tbl_attendance_2.idnumber WHERE (tbl_varsity_2.status = 'active') AND(tbl_varsity_2.idnumber != ALL (SELECT tbl_varsity_5.idnumber FROM tbl_varsity tbl_varsity_5 INNER JOIN tbl_attendance tbl_attendance_5 ON tbl_varsity_5.idnumber=tbl_attendance_5.idnumber WHERE (tbl_attendance_5.login BETWEEN '2012-11-23 00:00:00' AND '2012-11-25 00:00:00') AND (tbl_varsity_5.status='active')))
结果是
10169060 Shee-Ann G. Dela Cruz 2012-11-27 09:07:53 2012-11-27 14:08:03
< 我想将此值更改为[0000-00-00 00:00:00]> 乒乓球女子123456 Kevin S. Juanico 0000-00-00 00:00:00 0000-00-00 00:00:00
羽毛球男子12692070 Charie May C. Cudiamat 0000-00-00 00:00:00 0000-00-00 00:00:00篮球女子
这样所有的值都将是00:00:00
请帮助
答案 0 :(得分:0)
如果您希望0000-00-00 00:00:00
值显示在所有记录上(因为您没有指定任何条件),只需在select语句中使用它:
SELECT tbl_varsity_2.idnumber AS IDNUMBER
, CONCAT(tbl_varsity_2.firstname, ' ', tbl_varsity_2.middlename, '. ', tbl_varsity_2.lastname) AS NAME
/*, COALESCE(tbl_attendance_2.login, { d '0000-00-00 00:00:00' }) AS LOGIN
, COALESCE(tbl_attendance_2.logout, { d '0000-00-00 00:00:00' }) AS LOGOUT*/
, '0000-00-00 00:00:00' AS LOGIN
, '0000-00-00 00:00:00' AS LOGOUT
, tbl_attendance_2.totaltime AS TOTALTIME
, tbl_varsity_2.sport AS SPORT
FROM tbl_varsity tbl_varsity_2
LEFT JOIN tbl_attendance tbl_attendance_2 ON tbl_varsity_2.idnumber = tbl_attendance_2.idnumber
WHERE (tbl_varsity_2.status = 'active')
AND (tbl_varsity_2.idnumber != ALL (
SELECT tbl_varsity_5.idnumber
FROM tbl_varsity tbl_varsity_5
INNER JOIN tbl_attendance tbl_attendance_5 ON tbl_varsity_5.idnumber=tbl_attendance_5.idnumber
WHERE (tbl_attendance_5.login BETWEEN '2012-11-23 00:00:00' AND '2012-11-25 00:00:00')
AND (tbl_varsity_5.status='active')
)
)