First and Last Record Query
| From: | Rankin, Randy | Date: | Wed, 13 Feb 2002 17:32:32 +0000 |
| Subject: | First and Last Record Query | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-16906@lists.php.net to get a copy of this message | ||
Does anyone know how to grab only the first and last record of a query.
I have a table named periods with two fields, period_id and period_name. The
user will select a start period and an end period from a drop down list,
assigning $start_period and $end_period variables based on the period id. If
I run this query:
Select period_name
from periods
where period_id between '$start_period_id' and '$end_period_id'
order by period_id
An array is returned which could include one or more records, depending upon
the user selection. I would like to grab the first and last record in the
array so that the final result would be to echo something like "This report
is from $start_period through $end_period".
Hope that makes sense ...
Thanks in advance for any help.
Randy Rankin