我有两个表命名:
Custom_fields表的主键存在于Custom_field_value表中。每个用户都将拥有与自定义字段相关联但不包含所有字段的数据。我需要进行查询以查找特定用户ID的自定义字段的值。对于每个用户,我需要所有自定义字段及其值(即使值不存在)。我创建了以下查询:
"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";
但它只提供有价值的自定义字段,而不是提供值为none或为空的自定义字段。
请帮我解决此问题。
答案 0 :(得分:1)
请试试这个......
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
这肯定会解决你的问题...