Error calculating the maximum number
patient_id: 1,2,3,4,5,6,7,8,9,10
$result2=mysql_query("select max(patient_id) as maximum from outdoor");
$row2= mysql_fetch_array($result2);
echo $res=$row2['maximum'];
Its maximum number is 9 not 10.
+3
Akhila Prakash
source
to share
2 answers
try it
$sql = "select max(CONVERT(patient_id,UNSIGNED INTEGER)) as maximum from outdoor";
+1
Satish sharma
source
to share
use this
$sql = "select GREATEST(patient_id) as maximum from outdoor";
Use GREATEST ()
For example:
SELECT GREATEST(2,1);
0
Shakti patel
source
to share