To determine if a record exists in the table, the statements we have used routinely are:
Select COUNT (*) from tableName where conditions
If you are simply judging the existence of a record without needing to get the number of records in the actual table, there is a recommended practice on the Web:
if exists (SELECT * from tableName where conditions) SELECT ' 1 ' else select ' 0 '
Determine if there is a return value.
It is recommended that the second method is more efficient, but using the profiler tool to analyze
When more than 100 data is filtered through the Where condition. The durtion of the first method is significantly lower than that of the second method.
In other words, the first is more efficient. May I ask the second kind of situation in which the effect will be obvious?
SQL statement to determine if a record exists in the table