Since I said I&#39;d post a follow up (and I have worked it out after a coffee) using a LEFT OUTER JOIN I shall.<div><br></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">SELECT u.*</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">FROM   usr                                 AS u</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">       LEFT OUTER JOIN mahara.group_member AS gm</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">       ON     <a href="http://u.id">u.id</a>     = gm.member</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">WHERE  gm.member IS NULL</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">OR</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">       (</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">              gm.member IS NOT NULL</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">       AND    gm.group           != 10</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">       );</font></div>
<div><br></div><div>Working on the same principal.</div><div>We want every row from the usr table</div><div>That doesn&#39;t have an entry in <span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace; ">group_member </span>(so no member)</div>
<div>Unless that entry has a <font class="Apple-style-span" face="&#39;courier new&#39;, monospace">group</font> that isn&#39;t &#39;10&#39;</div><div><br></div><div>So you could also use:</div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">SELECT u.*</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">FROM   usr                                 AS u</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">       LEFT OUTER JOIN mahara.group_member AS gm</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">       ON     <a href="http://u.id">u.id</a>     = gm.member</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">WHERE  gm.group IS NULL</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">OR     gm.group      != 10</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">;</font></div></div><div><br></div>
<div>NOT IN statements are best avoided unless you have a small list of predefined items for performance purposes.</div><div><br></div><div class="gmail_quote">On 29 June 2011 10:07, Dan Attwood <span dir="ltr">&lt;<a href="mailto:danattwood@gmail.com">danattwood@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div class="im"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF"><div>Have you tested the subquery in php?<br></div></div></blockquote>
<div><br></div></div><div>I have and that&#39;s where it wasn&#39;t working. </div><div>However I have now found the reason and it was because I&#39;m a total idiot. Next time i&#39;ll double check i&#39;m look at the right database D&#39;oh</div>

</div>
<br>_______________________________________________<br>
Kent mailing list<br>
<a href="mailto:Kent@mailman.lug.org.uk">Kent@mailman.lug.org.uk</a><br>
<a href="https://mailman.lug.org.uk/mailman/listinfo/kent" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/kent</a><br></blockquote></div><br></div>