Question: I try to check which element is currently hover and adding class to div with the same data value

```
<a data-toggle="tooltip" title="Złącze słuchawkowe" data-id="#dialog1"
   class="single-image-item single-image-item-1" href="#" data-value="Headphones Plug">
     <i>1</i>
</a>
<a data-toggle="tooltip" title="Złącze słuchawkowe" data-id="#dialog2"
   class="single-image-item single-image-item-1" href="#" data-value="Charging Port">
     <i>1</i>
</a>

<div class="single-hot-spot-item" data-value="Headphones Plug">
     <span class="hot-spot-single-item hot-spot-item-1">1 </span>
     <p class="hot-spot-item-description">Złącze słuchawkowe</p>
</div>
<div class="single-hot-spot-item" data-value="Charging Port">
     <span class="hot-spot-single-item hot-spot-item-1">1 </span>
     <p class="hot-spot-item-description">Złącze słuchawkowe</p>
</div>

```

What is the best way to do this?

Answer: 
You need `EXISTS` with `NOT EXISTS` :

```
select m.* 
from table1 m
where exists (select 1 from table2 t where t.Id = m.Id and t.Status = 3) and
      not exists (select 1 from table2 t where t.Id = m.Id and t.Status = 3);

```
You can use `IN`. Just replace `= ANY` with `IN` and your code will work as you have expected.

```
select m.* from table1 m
inner join table2 I on m.Id = I.Id
where 
I.Id IN (select t.Id from table2 t where t.Id = I.Id and t.Status = 3) 
and 
I.Id IN (select t.Id from table2 t where t.Id = I.Id and t.Status <> 3)

```