i have a search query that i need to modify and adapt into a custom profile system we have, that system use the following table:
profile_key | profile_value | user_id
1 | test1 | 10
2 | test2 | 10
3 | ["test3","test4"] | 10
i need to add to the where clause something that would match all the rows (depending of what the user defined in the search form) to get the user_id, something like:
select user_id from table where (profile_key = 1 && profile_value regexp 'test1') && (profile_key = 3 && profile_value regexp 'test4')
i need to get all the user_id IF it matched all the defined profile_key and the regexp.
any idea how i can accomplish this?
Regards.
The simplest way would be to use
EXISTS:You could also accomplish this with an
INNER JOIN, once for each row you want to match: