SELECT fgallerycat.id, gallery_texts.title FROM fgallerycat INNER JOIN fgallery ON fgallerycat.id = fgallery.fgallerycat_id LEFT JOIN gallery_texts ON fgallerycat.id = gallery_texts.idtab AND gallery_texts.lan = 'es' AND gallery_texts.tabella = "fgallerycat" LEFT JOIN gallery_texts AS fgallery_texts ON fgallery.id = fgallery_texts.idtab AND fgallery_texts.lan = 'es' AND fgallery_texts.tabella = "fgallery" WHERE fgallerycat.status = 1 GROUP BY fgallerycat.id ORDER BY fgallerycat.pos