SELECT id, title_1 AS title, fullurl_1 AS url, (SELECT filename FROM product_categories_files WHERE parent_id=pc.id AND type="pictures" AND active=1 ORDER BY priority ASC LIMIT 0,1) AS display FROM product_categories AS pc WHERE active = 1 AND hidden = 0 AND parent_id = ORDER BY priority ASC