SQL查询没有给Android应用程序的欲望结果?

时间:2014-06-26 10:42:36

标签: android sql

我有两个表命名:

  1. Custom_fields - >(id,name,sequence)
  2. Custom_field_value - >(id,user_id,custom_field_id,custom_field_value)
  3. 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或为空的自定义字段。

    请帮我解决此问题。

1 个答案:

答案 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

这肯定会解决你的问题...