FQL查询仅获取具有生日的记录。

时间:2014-01-10 10:32:01

标签: android facebook facebook-fql

我想只从fb中获取指定生日的记录,我不想要空记录。我有以下查询:

String fqlQuery = "{" +
                        "'friends':'SELECT uid2 FROM friend WHERE uid1 = me()'," +
                        "'friendinfo':'SELECT uid, name, pic_square, birthday FROM user WHERE uid IN" +
                        "(SELECT uid2 FROM #friends)'," + 
                        "}";

它取出了所有内容,我尝试了以下内容:

String fqlQuery = "{" +
                        "'friends':'SELECT uid2 FROM friend WHERE uid1 = me()'," +
                        "'friendinfo':'SELECT uid, name, pic_square, birthday FROM user WHERE uid IN" +
                        "(SELECT uid2 FROM #friends)'," + "AND birthday != null"+
                        "}";

它没有给我任何结果,这样做的正确方法是什么?

1 个答案:

答案 0 :(得分:2)

在FQL中,只需使用AND something检查something是否为空。

以下是您更正的FQL查询:

{
'friends':'SELECT uid2 FROM friend WHERE uid1 = me()',
'friendinfo':'SELECT uid, name, pic_square, birthday FROM user 
               WHERE uid IN(SELECT uid2 FROM #friends) 
                 AND birthday'
}

Java代码:

String fqlQuery = "{" +
                        "'friends':'SELECT uid2 FROM friend WHERE uid1 = me()'," +
                        "'friendinfo':'SELECT uid, name, pic_square, birthday FROM user WHERE uid IN" +
                        "(SELECT uid2 FROM #friends) AND birthday'"+
                  "}";