Hola
jurena.
Te comento:
Cita:
Código MySQL:
Ver originalSELECT p.PRODUCT_ID
, IFNULL( COUNT( * ) , 0 ) total
, pa.APPLICATION_ID
, pm.MATERIAL_ID
LEFT JOIN t_products_applications pa
ON p.PRODUCT_ID
= pa.PRODUCT_ID
LEFT JOIN t_products_materials pm
ON p.PRODUCT_ID
= pm.PRODUCT_ID
GROUP BY pa.APPLICATION_ID
, pm.MATERIAL_ID
Esta consulta me saca el listado de los 127 productos que hay con su aplicación y con su material (ID's)
Lo que no entiendo es el campo TOTAL a qué hace referencia...
Yo obtengo un listado como este:
-----
PRODUCT_ID---------
total---------------
APPLICATION_ID---------------
MATERIAL_ID----
---------1------------------6--------------------12----------------------------5--------
---------18-----------------1--------------------12----------------------------8--------
---------1------------------5--------------------12----------------------------11------
---------80-----------------1--------------------12----------------------------14------
---------18-----------------1--------------------12----------------------------15------
---------80-----------------1--------------------12----------------------------17------
---------27-----------------1--------------------12----------------------------22------
---------28-----------------5--------------------12----------------------------23------
---------75-----------------1--------------------12----------------------------26------
---------18-----------------7--------------------13----------------------------5--------
---------47-----------------1--------------------13----------------------------6--------
---------32-----------------1--------------------13----------------------------7--------
---------18-----------------7--------------------13----------------------------8--------
---------31-----------------2--------------------13----------------------------9--------
---------24-----------------3--------------------13----------------------------10------
---------19-----------------5--------------------13----------------------------11------
---------49-----------------1--------------------13----------------------------12------
---------64-----------------1--------------------13----------------------------13------
---------2------------------8--------------------13----------------------------15------
---------39-----------------4--------------------13----------------------------17------
---------64-----------------1--------------------13----------------------------21------
---------27-----------------2--------------------13----------------------------22------
---------54-----------------1--------------------13----------------------------23------
---------83-----------------1--------------------13----------------------------25------
---------75-----------------1--------------------13----------------------------26------
---------3------------------2--------------------14----------------------------8-------
---------4------------------2--------------------14----------------------------9-------
---------19-----------------2--------------------14----------------------------11------
---------29-----------------2--------------------14----------------------------15------
---------13-----------------1--------------------14----------------------------19------
etc (hay más registros).
En este resultado NO aparecen todas las Aplicaciones ni todos los materiales... Seguimos con el mismo problema de que las que NO tengan productos relacionados NO a aparecen...
A ver si podemos llegar a la consulta final :)
Gracias de nuevo y un saludo
Javier