获取两个人的照片的FQL语句(查询不可索引错误)

时间:2010-11-25 03:16:21

标签: facebook facebook-graph-api facebook-fql

SELECT pid FROM photo WHERE me() and $otherPerson IN ( SELECT subject FROM photo_tag WHERE pid=pid ) ORDER BY created DESC LIMIT 1

我正在尝试获取一张用户标记在其中的照片($ otherPerson替换为用户ID)。此查询返回:

604 Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http://wiki.developers.facebook.com/index.php/FQL_Tables

关于如何使这项工作的任何想法?

更新:

我目前正在使用此查询,但我觉得有更好的方法可以解决。

SELECT pid, src_big FROM photo
 WHERE pid IN (
                 SELECT pid FROM photo_tag 
                 WHERE subject=$otherGuy
                 AND pid in (
                                SELECT pid FROM photo_tag WHERE subject=me()
                             )
               )

3 个答案:

答案 0 :(得分:3)

这应该可以解决问题。

SELECT pid, src_big
FROM photo
WHERE pid IN(
    SELECT pid  
    FROM photo_tag
    WHERE subject = me()
) 
AND pid IN(
    SELECT pid  
    FROM photo_tag
    WHERE subject = <friend_user_id>
)

答案 1 :(得分:0)

怎么样:

  SELECT pid
    FROM photo
   WHERE me() IN (SELECT subject
                    FROM photo_tag
                   WHERE pid=pid)
     AND $otherPerson IN (SELECT subject
                            FROM photo_tag
                           WHERE pid=pid)
ORDER BY created DESC
   LIMIT 1

此外,pid=pid的含义是什么?

答案 2 :(得分:0)

我尝试了其他解决方案并遇到了问题 - 如果您的朋友已将其隐私设置设置为禁止应用访问其照片,则以下FQL查询将返回一个空表:

"SELECT pid FROM photo_tag WHERE subject = <friend_user_id>"

我通过使用以下多重查询解决了这个问题:

"query1" : "SELECT subject, pid FROM photo_tag WHERE pid IN (SELECT pid FROM photo_tag WHERE subject=me())"
"query2" : "SELECT pid FROM #query1 WHERE subject= <friend_user_id>"