Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Search Query and MySQL help


Wythagy
Participant

@wythagy

Since I’m being ignored, I’ll try adding more info…

bp_xprofile_data table:

id | field_id | userd_id | value


1 | 2 | 30 | General
2 | 3 | 30 | Female
3 | 4 | 30 | Los Angeles
4 | 2 | 32 | Premium
5 | 3 | 32 | Female
6 | 4 | 32 | Boston
7 | 2 | 35 | General
8 | 3 | 35 | Male
9 | 4 | 35 | New York

What I want to do is search for all user_id’s that are “Male” and “General”, meaning I need to query where (field_id=2 and value=’General’) AND where (field_id=3 and value=’Male’).

Here is what I have and it doesn’t work:

$sql = “SELECT user_id FROM bp_xprofile_data WHERE value IN(‘General’,’Male’) HAVING COUNT(user_id) > 1”

This returns a value of “30”, corresponding to the first user in the table, however the first user is “Female”….not “Male” – when the search query SHOULD return user_id “35”.

so….one last time, I’m really trying here people….any help?

Skip to toolbar