I have a table like this :
id | user_id | param_id | param_value  
1      1          44          google
2      1          45         adTest
3      1          46         Campaign
4      1          47          null
5      1          48          null
6      2          44          google
7      2          45         adAnotherTest
8      2          46         Campaign2
9      2          47         null
10     2          48         null  
I want to fetch all the user_ids where (param_id = 44 AND param_value=google) AND (param_id= 45 AND param_value = adTest) . So the above where clause should give only user_id = 1 and not user_id = 2 . They both have google at param_id 44 but only user 1 has param_value adTest at param_id = 45 .
The problem is the n the future more params could be added . I need to find a dynamic query . Here what i have tryed :
SELECT DISTINCT up.user_id FROM user_params AS up
                    LEFT JOIN user_params AS upp ON up.id = upp.id
                    WHERE up.param_id IN (?,?) 
                    AND upp.param_value IN (?,?)
 
     
     
     
    