質問

I'm having trouble trying to select the lowest price and the unique url that's in the same row, at the moment it's getting the unique_url from the first row.

SELECT 
  MIN( price ), `unique_url` 
FROM `product_price` 
WHERE `barcode` = '" . $product_barcode . "' 
  AND `active`  = '1' 
GROUP BY `user_id` 
ORDER BY `price` ASC 
LIMIT 1

Help!

役に立ちましたか?

解決

Try this

SELECT MIN( price ) as mPrice, `unique_url` 
FROM `product_price` 
WHERE `barcode` = '" . $product_barcode . "' AND `active` = '1'
GROUP BY `user_id` 
ORDER BY mPrice ASC 
LIMIT 1
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top