怎么获取sql的SUM()值?紧急本人太菜
程序员文章站
2022-05-31 10:01:14
...
如何获取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 "
------解决方案--------------------
sql=mysql_query("select SUM(num) as sum from test1");
$res = mysql_fetch_array()
echo $res[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]
相关文章
相关视频