I have a sql search like below:
select distinct user_id from wp_usermeta where ( meta_key='postcode' and meta_value= '3000') or ( meta_key='state' and meta_value= 'vic') or ( meta_key='maternitybg' and meta_value= 'No')
My question is how do I change the query so it searches meta_value 3000, vic and No for user_id? All rows have user_id attached to it so this is why I’m using distinct function as it clears duplicates. The problem at the moment is it gets all users with meta_value of No and this is not what I want as I would like to filter by postcode and state aswell.
Any ideas?
1 Answer