2011年5月4日 星期三

[筆記]一些FQLs

本來是放在我EverNotes內的, 貼一些出來好了, 無聊時玩玩的東西, 沒優化過:

  • 共同喜歡的Page : select name from page where page_id in (select page_id from page_fan where uid=friend_uid and page_id in (select page_id from page_fan where uid=me()))
  • 共同朋友: select name from user where uid in (select uid2 from friend where uid1=me()) and uid in (select uid2 from friend where uid1=friend_uid)
  • 同時都出現的照片: select src from photo where pid in (select pid from photo_tag where subject=friend_uid) and pid in (select pid from photo_tag where subject=me())
  • 屬於某Group的照片: select src from photo where pid in (select pid from photo_tag where subject=group_id)
  • 共同參加的活動: select name from event where eid in (select eid from event_member where uid=me() and rsvp_status='attending') and eid in (select eid from event_member where uid=friend_id and rsvp_status='attending')
  • 都去過的地方(僅限於自己checkin不包含被tag): select name from place where page_id in (select page_id from checkin where author_uid=me()) and page_id in (select page_id from checkin where author_uid=friend_uid)
  • 喜歡過的某人的post:  select message from stream where post_id in (select post_id from like where post_id in (SELECT post_id FROM stream WHERE source_id=friend_uid) and user_id=me())
  • Comments on someone's post: select text from comment where post_id in (SELECT post_id FROM stream WHERE source_id=friend_uid) and fromid=me()

其中"me()"是自己, 有些FQL裡的"me()"可以代換成另一個人的uid