hi,
how do i do a SELECT statment that will just query a table to find the
row with the maximum of a declared field. for example, if i have a
table of customers and i would like to get the value of the last
customer to register so the SELECT statement would return only one
row, how would i do this?
also, the plan i have is to use a while loop (coz i dont know any
other) to get the colum value of each row:
$select = "SELECT ...
$result = mysql_query($se lect, $conn); //$conn will be predefined in
the code
while ($row = mysql_fetch_arr ay($result)) {
$date_added = $row['date_added'];
}
the while loop makes sense when outputting many rows but to get the
value of one column in one row, i dont know. it just seems a little
inefficient to use a while loop when i know there is only one row
returned (or will know), is this how all rows from a select statement
are queried or is there a more efficient way of doing this for this
situation? cheers
burnsy
how do i do a SELECT statment that will just query a table to find the
row with the maximum of a declared field. for example, if i have a
table of customers and i would like to get the value of the last
customer to register so the SELECT statement would return only one
row, how would i do this?
also, the plan i have is to use a while loop (coz i dont know any
other) to get the colum value of each row:
$select = "SELECT ...
$result = mysql_query($se lect, $conn); //$conn will be predefined in
the code
while ($row = mysql_fetch_arr ay($result)) {
$date_added = $row['date_added'];
}
the while loop makes sense when outputting many rows but to get the
value of one column in one row, i dont know. it just seems a little
inefficient to use a while loop when i know there is only one row
returned (or will know), is this how all rows from a select statement
are queried or is there a more efficient way of doing this for this
situation? cheers
burnsy
Comment