>>Normally EXISTS is used in situations where you need to correlate one table with another. In your case where is no correlation, so the above is better written as
>>
>>if exists(select 1 from ForumCli where NoMember = 1 and NoClient IN (1,2))
>>
>> select Numero from Thread where NoStatus = 1
>>
>>else
>>
>> select Numero from Thread where 1=0
>
>There is always at least one child record as per that condition. But, thanks for mentioning it.
The way your current EXISTS is written doesn't correlate with the parent table, which is wrong. If you want to check for existence of such child for the parent you need to add
and Child.Fk = Parent.PK into your exists test.
If it's not broken, fix it until it is.
My Blog