Skip to content

Tag: sql-server-2012

SQL Query Performance Enhancement on NOT IN

Suppose I have a query need to lookup users who bought book A but not bought book B. Typical SQL query can be: This not in query looks not efficient, any enhancement I can do this query? Answer Try using exists clause instead of IN clause – Apart from this you my try having index on below columns &#8211…