mysql - Select query with MAX(ad_number) issue -


$r = ca_mysql_query("select max(ad_number) `mytable`  `user` = {$user_id} ");  $max = $r[0]['ad_number']; echo $max; 

it should print max ad_number not returning value
wheares, if try query removing max(ad_number) returnig field data array.

$r = ca_mysql_query("select * `mytable`  `user` = {$user_id} ");  $max = $r[0]['ad_number']; 

is returning value given records

whats wrong ?

use alias column:

select max(ad_number) max_ad_number mytable  user = {$user_id} 

then this:

$max = $r[0]['max_ad_number']; echo $max; 

see documentation w3schools here


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -