mysql - Correct the query to fetch data from three different tables -
i have created following query.
select users.id, users.email, aucs.winner_id, aucs.beginner, accounts.user_id users, aucs, accounts users.id in ( aucs.winner_id ) , users.id not in ( accounts.user_id ) , aucs.beginner = '1'
i want select users email addresses appears once in aucs table in column winner_id aucs.beginner should equal '1' , user id not available in accounts table. have written query placed above not working.
this top of head, don't need accounts.user_id since wish records user_id not present in accounts.
select users.id users_id, users.email, aucs.winner_id, aucs.beginner users left join aucs on aucs.winner_id = users.id left join accounts on accounts.user_id = users.id aucs.beginner = '1' , accounts.id null group users.id having count(aucs.winner_id) = 1
Comments
Post a Comment