u1.id,
    u1.user_login,
    u1.display_name,
    m1.meta_value AS mobile_no,
    m2.meta_value AS aff,
    m3.meta_value AS aff_user_submit_id,
    m4.meta_value AS user_submit_count
FROM wp_users u1
Left JOIN wp_usermeta m1 ON (m1.user_id = u1.id AND m1.meta_key = 'mobile_no')
JOIN wp_usermeta m2 ON (m2.user_id = u1.id AND (m2.meta_key = 'aff_id' OR m2.meta_key = 'aff_user_submit_id'))
Left JOIN wp_usermeta m3 ON (m3.user_id = u1.id AND m3.meta_key = 'aff_user_submit_id')
Left JOIN wp_usermeta m4 ON (m4.user_id = u1.id AND m4.meta_key = 'aff_id' ) where m2.meta_value = m3.meta_value";


meta_key 값이 aff_user_submit_id 추천할사람
aff_id 추천당한사람인데요

갯수를 카운터할라니까 meta_key, meta velue 안에 값을 비교해야하니.. 햇갈리네요..ㅠㅠ

이런경우에는 어떤식으로 식을 만드나요?

답변주시면 감사하겠습니다..ㅠ