July 19th, 2000, 10:32 AM
I am trying to write a SQL(mySQL) query that would allow me to:
Select any 2 records with the minimum numeric value in a certain field (let's say minimum age). Also, if for example, 10 is the minimum age and there is only one record in the table with that age, that record should be selected along with the record where the age is higher (say 11).
Thanks in advance
July 19th, 2000, 02:43 PM
couldn't you do something like this:
select age from table order by age asc
which will get all of the ages, and sort them in accending order. then you can just get the first two rows.
you could possibly put a LIMIT on there to only retrieve two rows, but i've never used limits before...
July 19th, 2000, 09:31 PM
select * from table order by age limit 0,2