I have a table which is a mapping table t1. It looks like the following:

```
+-------+---------+-------------+
| Reqid | FIELDID | LISTITEMID  | 
+-------+---------+-------------+
|  219  | 76      |    3548     |
|  219  | 86      |    2382     |
|  220  | 76      |    3548     |
|  220  | 86      |    3491     |
|  221  | 77      |    3550     |
|  221  | 87      |    2387     |
+-----------------+-------------+

```

Now What I want todo is to select the distinct reqIds that has both of the following

```
select * from t1 where 
(FIELDID='76' and LISTITEMID='3548')    
or (FIELDID='77' and LISTITEMID='3550') 
or ((FIELDID='86' and (LISTITEMID='3491' or LISTITEMID='2380')) 
or (FIELDID='87' and (LISTITEMID='3494' or LISTITEMID='2386'))) order by REQUIREMENTID

```

This gives me all rows that has any one of those above requirements. But what I want todo is to get

```
 select * from t1 where 
    ((FIELDID='76' and LISTITEMID='3548') or (FIELDID='77' and LISTITEMID='3550')) 
    and 
(((FIELDID='86' and (LISTITEMID='3491' or LISTITEMID='2380')) 
    or (FIELDID='87' and (LISTITEMID='3494' or LISTITEMID='2386')))) order by REQUIREMENTID

```

The above obviously don't return any rows. But it points to what I want todo.

What the query should return is **220** since thats the only rows that contain both FieldID=76 and ListItemId=3548 and fieldId=86 and listItemId=3491.

Is this easily done in a query or do I have to write two separate querys and then create 2 arrays and compare which ids that occurs in both arrays?