sql >> Base de Datos >  >> RDS >> Mysql

Consulta MySQL Union duplicada/agrupada por problema

No todo es una unión, en este caso es una unión en las subconsultas:

SELECT shpUserAdded AS userName, merCount, prdCount
FROM (SELECT shpUserAdded, count(*) AS shpCount FROM shops GROUP BY shpUserAdded ASC) AS s
JOIN (SELECT prdUserAdded, count(*) AS prdCount FROM products GROUP BY prdUserAdded ASC) AS p
ON (shpUserAdded = prdUserAdded);