Hello
Using MySQL 5.0. I'm trying to select a set of data and somehow pick out rows with the smallest number in one of the columns.
Example:
[CODE=sql]
SELECT first_name, LEAST(height)
FROM people
INNER JOIN heights ON name_id_pk=name _id_fk
[/CODE]
I know LEAST() shouldn't be used like this but is there a way to do this?
The data in the table would be something like
people.first_na me: heights.height:
Henry 1.8
Henry 1.6
Henry 1.9
Arthur 1.5
John 1.8
John 1.7
The select query would pick out Henry (1.6), Arthur (1.5), John (1.7) as they are the smallest of each person with the same name.
Hopefully that makes sense. Any help is much appreciated.
Henry
Using MySQL 5.0. I'm trying to select a set of data and somehow pick out rows with the smallest number in one of the columns.
Example:
[CODE=sql]
SELECT first_name, LEAST(height)
FROM people
INNER JOIN heights ON name_id_pk=name _id_fk
[/CODE]
I know LEAST() shouldn't be used like this but is there a way to do this?
The data in the table would be something like
people.first_na me: heights.height:
Henry 1.8
Henry 1.6
Henry 1.9
Arthur 1.5
John 1.8
John 1.7
The select query would pick out Henry (1.6), Arthur (1.5), John (1.7) as they are the smallest of each person with the same name.
Hopefully that makes sense. Any help is much appreciated.
Henry
Comment