I have two MySQL tables: product
photo
Then I do INNER JOIN
SELECT *
FROM product
INNER JOIN photo
ON product.productID = photo.productID
But I need only one raw per unique product ID
If I try:
SELECT *
FROM product
INNER JOIN photo
ON product.productID = photo.productID
ORDER BY product.productID
It returns error
Expression #38 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'photo.photoID' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
The problem is photoID column. There are few photos per one product, but I need table with only first photo per product.
Can I do it with MYSQL tools like WHERE for example?
Thanks!