I have spent hours and still couldn't able to do it correctly. I have user table, and posts table.
username | followers | following
john | mary,steven,joel | anthony,matthew
fromuser | post | date
mary | Bla bla, today is cold. | 1475982647
SELECT * FROM posts WHERE $member[nick]
IN (SELECT followers FROM users WHERE $member[nick] IN followers ORDER BY id DESC limit 10
SELECT * FROM posts WHERE FIND_IN_SET(fromuser, (SELECT following FROM users WHERE username = 'john')) > 0
This query uses
FIND_IN_SET to check each user appearing in
posts whether or not he is being followed by a given user (John in this case).