I have a table where I need to figure out the very first ID and the
very last ID, so here is what I wrote:
$first_query = "SELECT id FROM mytable ORDER BY id LIMIT 1";
$first_result = mysql_query($first_query,$con);
$first_id = mysql_result($first_result,0,'id');
$last_query = "SELECT id FROM mytable ORDER BY id DESC LIMIT 1";
$last_result = mysql_query($last_query,$con);
$last_id = mysql_result($last_result,0,'id');
I'm just wondering if there was any way to do this more efficiently,
like with one query instead of two. Or is this about as simple as I
can do it?
Thanks.
--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada College
www.wnc.edu
775-445-3326