You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
487 B

SELECT
t.shixun_id,
t.user_id,
t.created_at,
t.updated_at
FROM
(SELECT DISTINCT
CONCAT(o.shixun_id, '_', o.user_id) tmp,
o.shixun_id,
o.user_id,
o.created_at,
o.updated_at
FROM
myshixuns o
WHERE o.user_id IN (SELECT id FROM users WHERE TYPE = 'User' AND (last_login_on >= 'LAST_LOGIN_TIME'))
) t
LEFT JOIN shixuns t1 ON t.shixun_id = t1.id
WHERE t1.hidden != 1 AND t1.status = 2 and (t.created_at >= 'LAST_CREATED_TIME');