<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial, helvetica, sans-serif;font-size:12pt"><avglsdata id=avglsdata></avglsdata> 
<DIV></DIV>
<DIV>Please, this should not be in development; it belongs in support.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Actually, Ivan's query won't work because each skill is on a separate row.&nbsp;Your query, AFAICT, is the only way the way to actually find multiple skill combinations. It also has the advantage of scaling to handle&nbsp;even more skills. But let's make it truly Drupalized:</DIV>
<DIV>&nbsp;</DIV>
<DIV>SELECT&nbsp;e.employee_id&nbsp;FROM {employees} e&nbsp;WHERE&nbsp;&nbsp;<BR>&nbsp;&nbsp;EXISTS(SELECT 1&nbsp;FROM {skills} s&nbsp;WHERE s.employee_id = e.employee_id&nbsp;AND s.skill_id = 'java')<BR>AND EXISTS(select 1&nbsp;FROM {skills} s&nbsp;WHERE s.employee_id = e.employee_id&nbsp;AND s.skill_id = 'C++')</DIV>
<DIV>&nbsp;</DIV>
<DIV>Of course, to use it in a db_query(), you will need to further parameterize it.</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New, courier, monaco, monospace, sans-serif">&nbsp; $skills_desired = array('java', 'c++', 'php');&nbsp; // Values can be filled however you prefer.</FONT></DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New">&nbsp; $wheres = array_fill(0, count($skills_desired), "EXISTS(SELECT 1&nbsp;FROM {skills} s&nbsp;WHERE s.employee_id = e.employee_id&nbsp;AND s.skill_id = '%s')");</FONT></DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New">&nbsp; $query = "SELECT&nbsp;e.employee_id&nbsp;FROM {employees} e&nbsp;WHERE " . implode(' AND ', $wheres);</FONT></DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New, courier, monaco, monospace, sans-serif"></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New, courier, monaco, monospace, sans-serif">&nbsp; if ($result = db_query($query, $skills_desired)) {</FONT></DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New, courier, monaco, monospace, sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;while ($result = db_result($result)) {</FONT></DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;// ... do something with the employee.</FONT></DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New, courier, monaco, monospace, sans-serif">&nbsp;&nbsp; &nbsp;}</FONT></DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New, courier, monaco, monospace, sans-serif">&nbsp; }</FONT></DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New, courier, monaco, monospace, sans-serif">&nbsp; else {</FONT></DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New">&nbsp;&nbsp;&nbsp; return t('No matches found.');</FONT></DIV>
<DIV><FONT color=#0000bf size=2 face="Courier New, courier, monaco, monospace, sans-serif">&nbsp; }</FONT></DIV>
<P><FONT size=2 face="Courier New, courier, monaco, monospace, sans-serif"></FONT>&nbsp;</P>
<P><FONT size=2 face="Courier New, courier, monaco, monospace, sans-serif"><FONT size=3 face="arial, helvetica, sans-serif">This is, of course,&nbsp;Drupal 6 code. DBTNG can do this more efficiently.</FONT><BR><BR></FONT>&nbsp;</P>
<P><FONT color=#ff007f size=4 face="bookman old style, new york, times, serif"><EM><STRONG>Nancy</STRONG></EM></FONT></P>
<P>&nbsp;</P>
<P><FONT face="arial, helvetica, sans-serif">Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.</FONT></P>
<DIV><BR></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 12pt"><BR><FONT size=2 face=Tahoma>
<DIV style="FONT-FAMILY: Courier New, monaco, monospace, sans-serif; FONT-SIZE: 10pt">
<HR SIZE=1>
</DIV>
<DIV style="FONT-FAMILY: Courier New, monaco, monospace, sans-serif; FONT-SIZE: 10pt"><B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> David Metzler</DIV>
<DIV style="FONT-FAMILY: Courier New, monaco, monospace, sans-serif; FONT-SIZE: 10pt"></FONT><BR>Select * form employees e where <BR>&nbsp; exists (select 1 from skills s where s.employee_id=e.employee_id and s.skill_id = 'java')<BR>AND exists(select 1 from skills s where s.employee_id=e.employee_id and s.skill_id='C++')<BR><BR>I have heard that mysql will perform better with Ivan's query, but I haven't verified that this is the case. <BR></DIV></DIV></div></body></html>