Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/01/2011, 10:17
Avatar de huesos52
huesos52
Colaborador
 
Fecha de Ingreso: febrero-2009
Ubicación: Manizales - Colombia
Mensajes: 5.980
Antigüedad: 15 años, 2 meses
Puntos: 360
Respuesta: Consulta sql: select join devuelva algo si no hay resultados.

prueba con el LEFT JOIN.

Código MySQL:
Ver original
  1. SELECT categorias.id, categorias.nombre_categoria, prod.tot
  2.         FROM categorias
  3.        LEFT JOIN (
  4.  
  5.         SELECT
  6.         if(COUNT( productos.id )>0,COUNT( productos.id ),0) as tot, categoria_id
  7.         FROM productos
  8.         GROUP BY categorias_id
  9.         ) AS prod ON prod.categoria_id = categorias.id
__________________
Without data, You are another person with an opinion.
W. Edwads Deming