I am trying to return a list of brands that do not have a specific product ID.
Using the following SQL:
SELECT Brands
FROM AllCustomers
WHERE ProductID NOT IN (SELECT ProductID WHERE ProductID ='10235')
Is there a more effective way to do this as it keeps timing out?
3
Answers
Given your subquery has the explicit ProductID in the where clause and the subquery is only returning the ProductID you could simplify your query to be
If you already have product ID, then why are you adding sub query ?
Simply write down query like:
Assuming you will actually use the same syntax for other queries, you didn’t specify a table in your sub-query.
Eg, if we are getting the filtered records of ProductID from the same table, it should be: