Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/07/2013, 23:37
Avatar de dvbeaumont
dvbeaumont
 
Fecha de Ingreso: marzo-2011
Ubicación: Caracas
Mensajes: 145
Antigüedad: 13 años, 1 mes
Puntos: 1
Exclamación Problema consulta mysql php

Hola Tengo esta consulta que funciona

Código MySQL:
Ver original
  1.         (SELECT count(*) AS cant  FROM  t_historia as tmp  WHERE puntuacion = 1) AS n1,
  2.         (SELECT count(*) AS cant  FROM  t_historia as tmp  WHERE puntuacion = 2) AS n2,
  3.         (SELECT count(*) AS cant  FROM  t_historia as tmp  WHERE (puntuacion = 3 OR puntuacion = 4)) AS n34,
  4.         (SELECT count(*) AS cant  FROM  t_historia as tmp  WHERE puntuacion >= 5) AS n5
  5.         FROM
  6.             t_historia
  7.         INNER JOIN
  8.             t_paciente_servicio
  9.         ON
  10.             t_historia.id_paciente = t_paciente_servicio.id_paciente
  11.         INNER JOIN
  12.             t_centro_servicio
  13.         ON
  14.             t_paciente_servicio.id_centro_servicio = t_centro_servicio.id_centro_servicio
  15.         WHERE
  16.             id_usuario= 99
  17.             LIMIT 0,1


y quiero hacer algo por el estilo

Código MySQL:
Ver original
  1.         (SELECT count(*) AS cant  FROM
  2.             t_historia
  3.         INNER JOIN
  4.             t_paciente_servicio
  5.         ON
  6.             t_historia.id_paciente = t_paciente_servicio.id_paciente
  7.         INNER JOIN
  8.             t_centro_servicio
  9.         ON
  10.             t_paciente_servicio.id_centro_servicio = t_centro_servicio.id_centro_servicio as tmp  
  11.         WHERE
  12.             puntuacion = 1 OR id_usuario= 99) AS n1,
  13.         (SELECT count(*) AS cant  FROM  t_historia as tmp  WHERE puntuacion = 2) AS n2,
  14.         (SELECT count(*) AS cant  FROM  t_historia as tmp  WHERE (puntuacion = 3 OR puntuacion = 4)) AS n34,
  15.         (SELECT count(*) AS cant  FROM  t_historia as tmp  WHERE puntuacion >= 5) AS n5
  16.         FROM
  17.             t_historia
  18.         INNER JOIN
  19.             t_paciente_servicio
  20.         ON
  21.             t_historia.id_paciente = t_paciente_servicio.id_paciente
  22.         INNER JOIN
  23.             t_centro_servicio
  24.         ON
  25.             t_paciente_servicio.id_centro_servicio = t_centro_servicio.id_centro_servicio
  26.         WHERE
  27.             id_usuario= 99
  28.             LIMIT 0,1

Pero no funciona :( no se que sera
__________________
Sé parte de nuestro mundo creativo.

http://bbcreativos.com