LEFT JOIN ManyToMany multiple parameters
<p>I have some problems with a MYSQL Query. I'm trying to do a <code>LEFT JOIN</code> with multiple parameters.</p>

<p>DB Structure:</p>

<p>A soldier can have more than one tag, these tags are assigned to the soldier with a ManyToMany relationship</p>

<p>My query is used in a search function where the user is able to add some tags he/she want to look for. So far its possible to search with one tag but as soon you add more than one tag, the query will not return an result even if it should.</p>

<p>Query used:</p>

<pre><code>SELECT *
FROM soldiers s LEFT JOIN
     soldier_tag st
     ON s.id = st.soldier_id
WHERE st.tag_id = 5;
</code></pre>

<p>When the user enters 2 tags, then both tags should math. The query will become this:</p>

<pre><code>SELECT *
FROM soldiers s LEFT JOIN
     soldier_tag st
     ON s.id = st.soldier_id
WHERE st.tag_id = 5 AND st.tag_id = 7;
</code></pre>

<p>Does anyone have an idea how I can fix this problem?</p>

<p>Thanks in advance</p>