Imagine a StudentDetails table in the below format

![Table Image with data](https://i.stack.imgur.com/8pKcm.png)

Create table query

```
 create table studentdetails (student_id bigint,key text,value text, primary key(student_id,key));
 insert into studentdetails values (1, 'class', 'class1'),(1, 'city', 'city1'),(2,'class','class2'),(2,'city','city2'),(3,'class','class2'),(3,'city','city2');

```

Select Query

```
select distinct student_id 
from studentdetails 
where ((key = 'class') 
   and (value = 'class2') 
   and (key = 'city' and value = 'city2'));

```

My requirement is to fetch students from city2 and class2 (ie: student\_id=(2,3)), but the above query returns 0 rows.

Note: I can not change the table structure.