> -----Original Message-----
> From: Jean-Pierre Schwickerath [mailto:[EMAIL PROTECTED]
>
> Hello Mumba, Hello Barry,
>
> > > How do I select out and filter only rows that match
> > > both 16 and 62 in the KEYW_ID col?  IE.  The query
> > > would return only 119 and 108?
> >
> > I'm sure this could be done more effeciently other ways, possibly with
> > a sub select if available, but something like this would probably
> > work:
> >
> >     SELECT temp1.*
> >     FROM table_name AS temp1
> >     LEFT JOIN table_name AS temp2
> >     ON temp1.tbl_idx=temp2.tbl_idx
> >     WHERE (temp1.keyw_id=16 AND temp2.keyw_id=62)
> >             OR (temp1.keyw_id=62 AND temp2.keyw_id=16);
> >
>
> I'm not sure which one is more efficient but I'd do it this way:
>
> SELECT * FROM table
> WHERE KEYW_ID = 16 OR KEYW_ID = 62
> GROUP BY TBL_IDX
> HAVING COUNT(TBL_IDX) = 2;

Neat - but I think this would give a false positive if there were two rows
with keyw_id = 16 or with keyw_id=62. If you know for certain that the
tbl_idx and keyw_id pair are unique in the table, then all would be fine.

 - Barry


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to