Advertisement
Unmanner

Untitled

Mar 20th, 2015
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.61 KB | None | 0 0
  1. SELECT SQL_NO_CACHE
  2.         a.*,
  3.         i.object_id,
  4.         u.phone, u.first_name AS first_name, u.email AS user_email, u.user_type,
  5.         ag.name AS agency_name, ag.phone AS agency_phone, ag.email AS agency_email, ag.url AS agency_site,
  6.     IFNULL(i.object_id, UUID()) AS unq_ancestor,
  7.     GROUP_CONCAT(i.gen_name, '.jpg' SEPARATOR ';') AS image_name
  8. FROM
  9.     objects a
  10.     LEFT JOIN object_images i ON a.id = i.object_id
  11.          JOIN users  u ON u.id = a.user_id
  12.     LEFT JOIN organizations ag ON ag.id = u.organization_id
  13. WHERE
  14.     a.object_status = 2
  15.     AND a.object_type IN (1, 2, 3, 4)
  16. GROUP BY a.id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement