SELECT id, nome, etc FROM table AS t, table AS t, etc LEFT JOIN table as t ON t.field = t.field AND t.field = t1.field WHERE field = value AND field = value ORDER BY field ASC field DESC GROUP BY field, field LIMIT 1/1