1. select * from `posts` where `user_id` in
  2. (
  3. (select `id` from `users` where `name`='ali'
  4. union
  5. select `followed_id` from `following` where `following_id` in
  6. (select `id` from `users` where `name`='ali')
  7. )
  8. );