I have the following problem:
When i execute a query on Azure SQL, the second AND condition runs, even when the first one is false.
The table "items" contains 2048 items with the column 'Claimd' =1 and only one item with Claimd=0.
That one item is also the item which has a description containing the word "razer".
SET STATISTICS TIME on
SELECT * FROM dbo.Items
WHERE Claimd=0 AND
([Description] LIKE '%razer%' OR [Name] LIKE '%razer%')
Result: elapsed time of 143 ms
If I just search on Description, I get the following result:
SET STATISTICS TIME on
SELECT * FROM dbo.Items
WHERE Claimd=0 AND
[Description] LIKE '%razer%'
Result: elapsed time of 1 ms
There is only one item with Claimd=0, so that explains why the result is show in 1 ms. But when I want to search on a second column, with an OR condition, it's like it's searching the whole table again instead of only those with the flag "Claimd"=0
Is there something wrong with my brackets? I would really like to know why that second AND statement is executing when adding an OR statement, even if the first statement is false.