嗯,
我的这张表有一个计算的到期日,其中课程完成+ 1年=到期日。
现在我想获取已经过期的用户的记录。这意味着我将比较今天的到期日期。
SELECT
employee.data AS 'Employee No.',
CONCAT(u.firstname,' ',u.lastname) AS 'Full Name',
CONCAT('<a target="_new" href="%%WWWROOT%%/user/profile.php?id=',u.id,'">', u.username,'</a>') AS 'User Name',
org.data AS 'Organisation',
c.fullname AS 'Course',
DATE_FORMAT(FROM_UNIXTIME(p.timeenrolled),'%m/%d/%Y') AS 'Enrollment Date',
DATE_FORMAT(FROM_UNIXTIME(p.timecompleted),'%m/%d/%Y') AS 'Completion Date',
DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(p.timecompleted),INTERVAL 1 YEAR), '%m/%d/%Y') AS 'Expiration Date'
FROM prefix_course_completions p
JOIN prefix_course c ON p.course = c.id
JOIN prefix_user u ON p.userid = u.id
LEFT JOIN (
SELECT d.userid, d.data
FROM prefix_user_info_data d
JOIN prefix_user_info_field f ON f.id = d.fieldid AND f.shortname = 'employeeid'
) employee ON employee.userid = u.id
LEFT JOIN (
SELECT d.userid, d.data
FROM prefix_user_info_data d
JOIN prefix_user_info_field f ON f.id = d.fieldid AND f.shortname = 'Organisation'
) org ON org.userid = u.id
WHERE DATE((FROM_UNIXTIME(p.timecompleted),INTERVAL 1 YEAR) < CURDATE()
%%FILTER_COURSES:Course%%
%%FILTER_USERS:org.data%%
%%FILTER_SEARCHTEXT:employee.data:~%%
ORDER BY employee.data
每当我尝试使用此
时,它总是给我错误WHERE DATE((FROM_UNIXTIME(p.timecompleted),INTERVAL 1 YEAR) < CURDATE()