Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在查询数据库中的 2 个表。如果用户在同一天多次显示,我想添加 hours_worked 字段的值。这就是我开始的:
SELECT name, date_worked, hours worked FROM users u INNER JOIN records r ON u.id = r.users_id .......
这就是我所得到的。有关如何执行此操作的 SQL 语法的任何帮助会很棒吗?
只是聚合它使用SUM
SUM
SELECT name, date_worked, SUM(`hours worked`) AS totalHoursWorked FROM users u INNER JOIN records r ON u.id = r.users_id GROUP BY name, date_worked