SELECT
*
FROM
myTable
WHERE
field1 LIKE 'match0' AND
myfunc(t1.hardwareConfig) LIKE 'match1'
Here is my question,
the matching of field1 is fast and quick, but myfunc takes forever to return and I want to make sure that if field1 doesn’t match that it doesn’t even attempt to do myfunc.
Will SQL just know this or can I make it explicit in my query?
I’m on MSSQL 2000, 2005 and 2008, hopefully there’s a common answer.
To enforce the order in which conditions are evaluated, use the following approach, because it is documented that CASE preserves the order in which conditions are evaluated.
The following article explains it in good detail: Predicates in SQL