SELECT p.*, p1.name_pic FROM links_bg as p LEFT JOIN links_pics as p1 ON p.id = p1.id_p LEFT JOIN links_pics as p2 ON p1.id_p = p2.id_p AND p1.weight > p2.weight where p2.id_p is null AND p.status=1 Table 'osogov_website.links_pics' doesn't exist ВРЪЗКИ
1 2 3 4 5