I\'m trying to write a MySQL query where I pull a seller\'s info and her most popular product. This is determined by the product with the most page views, i.e. MAX(pa
SELECT a.ID SellerID,
a.Shop_Name,
b.ID ProductID,
b.pageViews,
b.title,
b.Price
FROM seller a
INNER JOIN Products b
ON a.id = b.seller_ID
INNER JOIN
(
SELECT seller_ID, MAX(pageViews) max_view
FROM products
GROUP BY seller_ID
) c ON b.seller_ID = c.seller_ID AND
b.pageViews = c.max_View
WHERE a.handpicked = 'Y' AND a.active = 'Y'
OUTPUT
╔══════════╦═══════════╦═══════════╦═══════════╦═════════╦═══════╗
║ SELLERID ║ SHOP_NAME ║ PRODUCTID ║ PAGEVIEWS ║ TITLE ║ PRICE ║
╠══════════╬═══════════╬═══════════╬═══════════╬═════════╬═══════╣
║ 1 ║ mitienda ║ 2 ║ 30 ║ bufanda ║ $25 ║
║ 3 ║ new_world ║ 6 ║ 6 ║ ropa ║ $13 ║
╚══════════╩═══════════╩═══════════╩═══════════╩═════════╩═══════╝