Reputation: 2396
I have two tables naming :
The primary key of Custom_fields table is present in Custom_field_value table.Every user will have data associated with custom fields but not for all the fields.I need to make a query to find out the values of custom fields for a particular user id.For every user I need all custom field and their values(even if value is not present).I created the following query:
"SELECT alumni_custom_fields. _id,
alumni_custom_fields.field_label as key ,
alumni_custom_field_data.custom_field_value as value
FROM alumni_custom_fields LEFT JOIN alumni_custom_field_data
ON alumni_custom_fields._id=alumni_custom_field_data.custom_field_id " +
"WHERE alumni_id ='"+alumniId+"' order by sequence";
But its only giving the custom fields which has value and not giving me the custom fields whose value is none or empty.
Please help me fix this query.
Upvotes: 0
Views: 27
Reputation: 78
Please try this.....
SELECT alumni_custom_fields. _id,alumni_custom_fields.field_label as key ,alumni_custom_field_data.custom_field_value as value FROM alumni_custom_fields LEFT JOIN alumni_custom_field_data ON alumni_custom_fields._id=alumni_custom_field_data.custom_field_id and alumni_id ='"+alumniId+"' order by sequence
This will surely solve your problem...
Upvotes: 1