Query not using not exist

43 Views Asked by At

How to rewrite the below query by not using not exist and the performance is better than using not exist

SELECT m.member
  FROM  member        m
 WHERE 1 = 1
   AND NOT EXISTS (
       SELECT NULL
         FROM history c
            , tender  t
      WHERE 1 = 1
        AND c.card_type        =  t.tender_type
        AND c.member           =  m.member
       AND 1 = 1 )
    AND 1 = 1;

Thanks is advance for all your help.

1

There are 1 best solutions below

0
On

You haven't described what problem you're trying to solve.

It looks like maybe you're trying to get a list of members who have no history?

select 
    m.member
from 
    member m
    left join history c on c.member = m.member
where
    c.member is null

Adding clarification to your question might help. Can you provide the DDL of your tables and explain in english what you would like the query to return?