Here is the table structure:
cdata_id
users_id
field_id
value
I am interested in only some of the fields value's for the users.
Here is what I am using now:
$query = "SELECT lm_users.users_id, lm_cdata.cfield_id, lm_cdata.value FROM lm_users
INNER JOIN lm_cdata ON lm_users.users_id = lm_cdata.user_id WHERE lm_users.group_id =2
AND (
lm_cdata.cfield_id = '1'
OR lm_cdata.cfield_id = '2'
OR lm_cdata.cfield_id = '3'
OR lm_cdata.cfield_id = '11'
OR lm_cdata.cfield_id = '12'
OR lm_cdata.cfield_id = '9'
) order by lm_users.users_id";
But this means I have to do all of my own sorting for tree like structure in programming. Is there any way to sort this using SQL?
This is how I wish to use the data from this query:
Country 1 (cfield_id= 2) [Start with United States, then followed alpha by other countries]
State 1 (cfield_id= 1)
City (cfield_id= 3)
Participant 1 (cfield_id= 9)
event description (cfield_id= 12)
Participant 2 (cfield_id= 9)
event description (cfield_id= 12)
City 2 (cfield_id= 3)
Participant 3 (cfield_id= 9)
event description (cfield_id=12)
Participant 4 (cfield_id= 9)
State 2 (cfield_id= 1)
I have been struggling for several days on this. Any help or advice would be so much appreciated.
Seeking sanity,
KerKor
Start Free Trial