Advertisement
Max13

Untitled

Jul 9th, 2012
591
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.81 KB | None | 0 0
  1. SELECT `timeline`.`action`, `timeline`.`data`, `timeline`.`tlupdate`,
  2.     u1.`id` AS ufrom_id, u1.`username` AS ufrom_username, u1.`firstname` AS ufrom_firstname, u1.`lastname` AS ufrom_lastname, u1.`picture` AS ufrom_picture,
  3.     u2.`id` AS uto_id, u2.`username` AS uto_username, u2.`firstname` AS uto_firstname, u2.`lastname` AS uto_lastname, u2.`picture` AS uto_picture,
  4.     m.`id` AS m_id, m.`name` AS m_name, m.`alternative_name` AS m_altname, m.`tiny_img` AS m_tiny, m.`normal_img` AS m_normal
  5. FROM `timeline`
  6. JOIN `users` u1 ON u1.`id` = `timeline`.`user_id_from`
  7. JOIN `users` u2 ON u2.`id` = `timeline`.`user_id_to`
  8. JOIN `movies` m ON m.`id` = `timeline`.`movie_id`
  9. WHERE u1.`id` IN
  10. (
  11.     SELECT `idol_id`
  12.     FROM `friends`
  13.     WHERE `fan_id` = ?
  14. )
  15. OR u2.`id` IN
  16. (
  17.     SELECT `idol_id`
  18.     FROM `friends`
  19.     WHERE `fan_id` = ?
  20. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement