如何反转mysql查询?

时间:2012-12-04 12:47:18

标签: mysql

有谁知道如何反转以下mysql查询?

select * 
from test_results 
where TESTERID='3' 
  and TESTID IN (select TESTID 
                 from tests 
                 where TESTSREQUESTED > '0' 
                   AND TESTSREQUESTED > TESTSREQUESTEDTAKEN);

谢谢!

3 个答案:

答案 0 :(得分:2)

select * from test_results where not (TESTERID='3' and TESTID IN (select TESTID from tests where TESTSREQUESTED>'0' AND TESTSREQUESTED>TESTSREQUESTEDTAKEN))

答案 1 :(得分:0)

试试这个::

select
 * 
from test_results tr
INNER JOIN tests  on (tests.TESTID=tr.TESTID)

where tr.TESTERID!='3' 
OR (tests.TESTERID!='3' AND tests.TESTSREQUESTED<'0' AND TESTSREQUESTED<TESTSREQUESTEDTAKEN) 

答案 2 :(得分:-1)

试试这个

select * from test_results where TESTERID!='3' and TESTID NOT IN (select TESTID from tests where TESTSREQUESTED>'0' AND TESTSREQUESTED>TESTSREQUESTEDTAKEN)