我有桌子:
tb_keterangan
colDate | colKeteranganID | colUser ID
2012-08-01 | 1 | 1
2012-08-03 | 2 | 1
我有这样的查询:
SELECT cal.myDate as colDate,
t.colJamMasuk,
t.colJamKeluar,
t.colTerlambat,
t.colLemburPagi,
t.colLemburSore,
b.colKeterangan,
c.colKeteranganID
FROM (SELECT s.start_date + INTERVAL (tb_days.day) DAY as myDate
FROM (SELECT DATE_ADD(MAKEDATE(2015, 31), INTERVAL (07-2) MONTH) AS start_date,
DATE_ADD(MAKEDATE(2015, 1), INTERVAL (07) MONTH) AS end_date) AS s
JOIN tb_days
ON tb_days.day < DATEDIFF(s.end_date, s.start_date)) AS cal
LEFT JOIN tb_libur AS b
ON b.colTanggal = cal.myDate
LEFT JOIN tb_kehadiran AS t
ON t.colDate >= cal.myDate AND
t.colDate < cal.myDate + INTERVAL 1 DAY AND
t.colUserID = 1
ORDER BY colDate
我想将tb_keterangan表加入我的查询。