I have this query that checks if some id's exists in a table it modifies the value of another column.

```
IF EXISTS (SELECT A.id,description,ab FROM tbl_C C
  JOIN tbl_B B ON ba=C.id
  JOIN tbl_A A ON A.id=B.value
  WHERE a=3)
    BEGIN UPDATE tbl_A
  SET ab=1
  where ab=0
  END
  ELSE 
   PRINT N'No values'

```

What happens here is that it modifies all the values, not only the ones in the IF EXISTS condition. How can I update only the ones that are selected in the IF EXISTS condition?