Mysql
 SQL >> Base de Dados >  >> RDS >> Mysql

Obter o total de valores de diferentes usuários no MySQL e PHP

SELECT MIN(a.ID) ID, a.name, SUM(b.Price) Price FROM table1 a INNER JOIN table2 b ON a.PID = b.PID GROUP BY a.Name 

SAÍDA

╔════╦══════╦═══════╗ ║ ID ║ NAME ║ PRICE ║ ╠════╬══════╬═══════╣ ║ 1 ║ ram ║ 4333 ║ ║ 2 ║ rani ║ 2000 ║ ╚════╩══════╩═══════╝