I am working in a project which needs top performance in SQL results, and was looking to optimize a query, but after some trial and error I am having some trouble with IN.
-- THIS RETURNS NO RESULTS AT ALL.
SELECT sysdba.HISTORY.TICKETID FROM sysdba.HISTORY
where TICKETID = 't6UJ9A002MJC'
-- THIS RETURNS 4 RESULTS.
SELECT sysdba.C_TICKETPROVIDERS.* FROM sysdba.C_TICKETPROVIDERS
where sysdba.C_TICKETPROVIDERS.TICKETID = 't6UJ9A002MJC'
-- THIS RETURNS NO RESULTS AT ALL.
SELECT sysdba.C_TICKETPROVIDERS.* FROM sysdba.C_TICKETPROVIDERS
where sysdba.C_TICKETPROVIDERS.TICKETID NOT IN
(SELECT DISTINCT sysdba.HISTORY.TICKETID FROM sysdba.HISTORY)
Shouldn't the last query result at least the same 4 results as the previous one, since there are no matching results???