[EMAIL PROTECTED] wrote: > > Sorry. My english is not so good. :( > I try to explain. > > I have table1 : > > ID value > -------------------------- > 1 100 > 1 101 > 1 102 > 1 200 > 2 100 > 2 300------------------- > 2 310 | > 3 100 | > | > and table2: | > | > value | > ----------- | > 300 <----------------------------- > > > The result of the query should be from IDs of table1 (In this case 1,3) . > The ID 2 is not allowed, because the table2 is the exception table wich is > containing the value 300. >
You need something like: SELECT DISTINCT t3.id FROM table2 t2 INNER JOIN table1 t1 ON t1.value=t2.value RIGHT JOIN table1 t3 ON t1.id=t3.id WHERE t1.id IS NULL; -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Egor Egorov / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]