Ver Mensaje Individual
  #4 (permalink)  
Antiguo 07/05/2011, 16:42
alexg88
 
Fecha de Ingreso: abril-2011
Mensajes: 1.342
Antigüedad: 13 años
Puntos: 344
Respuesta: Subquery para obtener 2 valores

Podría funcionar algo así, pruebalo a ver que sale:

Código SQL:
Ver original
  1. SELECT tp.name, tp.id,  SUM(st1.`like`), SUM(st1.dislike), SUM(st1.visits) 
  2. FROM tablaPrincipal tp
  3. JOIN subTabla2 st2  ON tp.id = st2.tpid
  4. JOIN subtabla st1 ON st2.id = st1.st2id
  5. GROUP BY tp.id, tp.name