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
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]
Looks like some needs to catch up on the term 'NORMALIZATION' ...
Don't store diffent kinds of data in one table/column ...
That is, value is either a Country, a State, a City, a Participant ... but not all of them. So the problem lies in the database structure, not the query ... what you want to achieve with the given table structure is 'somewhat complicated'.
... at least, that what I kind of understand from it.
> SELECT * FROM users WHERE clue > 0;
Empty set (0.00 sec)