Brug aggregatfunktionen MIN
:
SELECT MIN(date_added) AS OldestDate
FROM products_to_categories
WHERE products_id = 2085;
Hvis du leder efter den ældste dato for hvert produkt, skal du tilføje en GROUP BY
:
SELECT products_id, MIN(date_added) AS OldestDate
FROM products_to_categories
GROUP BY products_id;