How to select data where a field has a min value in MySQL?

Sami El Hilali picture Sami El Hilali · Nov 13, 2012 · Viewed 124.5k times · Source

I want to select data from a table in MySQL where a specific field has the minimum value, I've tried this:

SELECT * FROM pieces WHERE MIN(price)

Please any help?

Answer

John Woo picture John Woo · Nov 13, 2012

this will give you result that has the minimum price on all records.

SELECT *
FROM pieces
WHERE price =  ( SELECT MIN(price) FROM pieces )