Advanced Inner Join between User, User_Group and Subscriptions Tables
<p>I have Three tables:</p>

<pre><code>Users          { id | name | email }
User_Group     { User_id | group_id }
Subscriptions  {user_id, sub_level }
</code></pre>

<ul>
<li>User can be signed to more that User group.</li>
<li>User can be subscribed to more than subscription plan.</li>
</ul>

<p>Let's suppose we have:</p>

<p>Table Users:</p>

<pre><code>[1, John, john@email.com]

[2, Lara, lara@email.com]
</code></pre>

<p>Table User Group:</p>

<pre><code>[1,6]  // User 1 is assigned to Group 6

[1,3]  // User 1 also assigned to Group 3

[2,3]  // User 2 in ONLY assigned to Group 3 
</code></pre>

<p>Table Subscriptions :</p>

<pre><code>[1, 8] // User 1 have subscription level 8

[2, 8] // User 2 have subscription level 8

[2, 9] // Also User 2 have subscription level 9
</code></pre>

<p>What I want to get is: </p>

<p>All UNIQUE users who are assigned to ONLY group 3 and who have at least one subscription.   </p>

<p>What I have tried: </p>

<pre><code>SELECT U.Username, U.email, G.group_id, S.sub_level FROM `Users` AS U
INNER JOIN `User_Group` AS G
ON U.id = G.user_id
INNER JOIN `Subscriptions` AS S
ON U.id = S.user_id
WHERE G.group_id = 3
Limit 0,10
</code></pre>

<p>Problem it will display users who are also assigned to others groups like user 1 who is in group 6 and 3. Also it will display duplicate lines because one user can have many subscription levels.</p>