我为我的 php 脚本使用了 2 个表。
define("EXTRA_POINTS_VALUE",15);
table "points":
id_user | point
1 | 500
2 | 650
3 | 400
table "points_extra":
id_point_extra | id_user
1 | 1
2 | 1
3 | 1
4 | 2
我需要在一个查询中使用 COUNT(id_extra_point) * EXTRA_POINTS_VALUE 的 SUM 字段“points.point”。这是可能的?
结果必须是这样的:
id_user | total_point
1 | 545 (500 + (3 count * 15))
2 | 665 (650 + (1 count * 15))
3 | 400 (400 + (0 count * 15))