怎么获取sql的SUM()值?紧急本人太菜
时间:2021-07-01 10:21:17
帮助过:87人阅读
如何获取sql的SUM()值?紧急!在线等!本人太菜
有一个表test1
字段名num
有三个字段 111 222 333
$sql=mysql_query("select SUM(num) from test1");
$a=xxx($sql);
接下来该用哪个函数xxx把666这个数取出来赋予变量啊???
万分感激
------解决方案--------------------
sql=mysql_query("select SUM(num) as t_sum from test1");
$res = mysql_fetch_array()
echo $res[t_sum]
------解决方案--------------------
$a=mysql_fetch_array($sql);
echo "
";
print_r($a);
echo "
";
------解决方案--------------------sql=mysql_query("select SUM(num) as sum from test1");
$res = mysql_fetch_array()
echo $res[sum]