I am trying to get the body and the sender of all unread inbox .
To get all conversation\'s threads with unread messages I used this query:
SELECT thre
This works:
SELECT sender, body FROM unified_message
WHERE thread_id IN
(SELECT thread_id FROM unified_thread WHERE folder = 'inbox' AND unread=1)
AND unread=1
ORDER BY timestamp DESC
It is important to sort the messages you retrieve in a descending order using:
ORDER BY timestamp DESC
Otherwise, only the first older messages of the conversation will be examined, whereas unread messages should be recent.
Just for your knowledge, here is the corresponding multi-query, which gives the same result:
{
"threads":"SELECT thread_id FROM unified_thread WHERE folder='inbox' AND unread=1",
"messages":"SELECT sender, body FROM unified_message WHERE thread_id IN (SELECT thread_id FROM #threads) AND unread=1 ORDER BY timestamp DESC"
}
However, you should not use FQL anymore:
Version 2.0 of the Facebook Platform API is the last version where FQL will be available. Versions after 2.0 will not support FQL. Please migrate your applications to use Graph API instead of FQL. Please see our changelog for current version information.
I suggest you use the following Graph API tables:
By the way, FQL doesn't have such INNER JOIN
.