2014-01-10 63 views
1

我想只抓取那些有指定生日的fb記錄,我不想要空記錄。我有以下查詢:FQL查詢僅提取那些有生日的記錄。

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"+ 
         "}"; 

它不給我任何結果,什麼是這樣做的正確方法是什麼?

回答

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'"+ 
        "}"; 
+0

作品完美無瑕的,謝謝:) – Skynet

+0

而且最後一個查詢,我可以獲取私人信息,如電話號碼和電子郵件? – Skynet

+1

雖然可以通過電子郵件字段檢索電子郵件,但無法獲取電話號碼。 –