我有一个查询,我需要用联接替换子查询。
SELECT DISTINCT m.prob_id, m.*, m.id as mh_trans_id, v.id as unlock_id
FROM (
SELECT * FROM m_trans
WHERE type = '1' AND is_test = '0' AND posted_on >= '2018-05-01'
AND prob_id IS NOT NULL
AND is_p = 1
GROUP BY prob_id HAVING count(*) = 1
) as m
LEFT JOIN vid_u v ON m.i_id = v.v_id AND m.u_id = v.u_id
WHERE status = 'success' AND v.id IS NULL
GROUP BY m.i_id, m.s_u_id, m.u_id
ORDER BY m.p_on ASC;