Try to build the following "table": IDJOB | IDKIT | IDJOB2
4 | 19 | 4 4 | 19 | 4 4 | 19 | 4 4 | 19 | 4 4 | 19 | 2 4 | 19 | 2 2 | 19 | 4 2 | 19 | 4 2 | 19 | 2 2 | 5 | 2 (some join) Then throw lines with IDJOB=2, group by IDKIT, with max(IDJOB2=2) You'll get: IDKIT | max(IDJOB=2) 19 | 1 Take lines with max(IDJOB=2)=0 Hope that helps, Oren. -----Original Message----- From: Matteo Ferrari [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 07, 2002 12:56 PM To: [EMAIL PROTECTED] Subject: instead of subquery? Hi. I have this table (A) IDJOB ¦ IDKIT 4 ¦ 19 4 ¦ 19 2 ¦ 19 2 ¦ 5 I need to extract IDKIT with IDJOB<>2 if and only if IDKIT <> IDKIT when IDJOB=2 In this case my query should return null With a subquery I can do this and it works SELECT idkit from A where A.id_job<>2 and A.id_kit not in (select A.id_kit from A where A.id_job=2) Anyone could suggest how I could do this in mysql without subquery? Thanks in advance Matteo --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php