mysql count last_column_data not working -


i have table name: serial

id            name             date ----          --------         -----------            1             george           2013-07-24 2             john             2013-07-24 3             thomas           2013-07-25 4             james            2013-07-31 5             andrew           2013-07-20 6             martin           2013-07-24 7             william          2013-07-21 8             zachary          2013-07-25 9             millard          2013-07-31 10            chester          2013-07-24 

now need count of last value of column date dynamically, here last value of column date 2013-07-24, count 4. if data insert id#11 date value 2013-07-31,then count 3. have made function this:

function countdate(){        $sql = "select count( `id` ) countdate serial `date` = 'last(date)'";      $result = mysql_query($sql);         $cd= mysql_fetch_array($result);     return $cd['countdate']; }    

but not working. if put directly '2013-07-24' instead of 'last(date)' function, gives result. think 'last(date)' not working here dynamically. mistake here or other way......by way, not expert coder, , it's first question, so...

here max(value) might not work different dates insert here. max(value) may work here if consider column 'id'. values of column 'date' not incremental here.

try sub query: select count(*) countdate serial `date` = (select `date` serial order id desc limit 1)


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -