-1

我有一张桌子,里面有很多文章,每篇文章都有很多浏览量。我如何计算所有视图?

表示例:

-----------------------------
id | title | content | views
-----------------------------
1 | name | thecontent | 15
2 | name | thecontent | 22
3 | name | thecontent | 6
4 | name | thecontent | 49

总浏览量:92

谢谢你。

4

4 回答 4

1

SQL查询

SELECT SUM(column_name) FROM table_name;<br>

PHP:

$result = mysql_query('SELECT SUM(value) AS value_sum FROM codes'); <br>
$row = mysql_fetch_assoc($result); <br>
$sum = $row['value_sum'];<br>
于 2013-10-03T18:01:50.857 回答
1

使用SUM()功能。

试试这个查询...

SELECT SUM(views) as total_views FROM table_name
于 2013-10-03T17:59:51.310 回答
0

SELECT SUM(views) AS views FROM <table name>?

于 2013-10-03T18:00:15.127 回答
0

您可以使用 MySQL 的SUM()功能来完成。

SELECT SUM(views) as num_views FROM TBL_NAME
于 2013-10-03T18:00:34.977 回答