SELECT e.album_id

  FROM jos_hwdms_media as m

  LEFT JOIN jos_hwdms_album_map e 
  ON m.id = e.media_id

  LEFT JOIN jos_hwdms_category_map as h 
  ON m.id = h.element_id

  LEFT JOIN jos_categories as cat 
  ON cat.id = h.category_id

  LEFT JOIN jos_users as u1 
  ON m.created_user_id = u1.id

  LEFT JOIN `jos_hwdms_users` AS u 
  ON u.id = u1.id

  WHERE u.access IN (1,1,2,3,4,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,27,28,30) 
  AND u.status = 1 
  AND u.private = 0 
  AND cat.published = 1 
  AND (m.language = 'en-GB' || m.language = '*' ) 
  AND m.access IN (1,1,2,3,4,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,27,28,30) 
  AND m.published = 1 
  AND e.album_id!='' 
  GROUP BY e.album_id