La siguiente consulta ejecutada en Workbench
Código SQL:
Ver original
SELECT C.idcategorie, C.iduser, C.categorie, S.idsubcategorie, S.idcategorie, S.subcategorie, COUNT(S.idsubcategorie) AS count_subc FROM categories C LEFT JOIN subcategories S ON C.idcategorie=S.idcategorie GROUP BY C.idcategorie
Genera este resultado
![](http://i59.tinypic.com/nmnvbm.jpg)
Pero al ejecutar la consulta con PHP resulta que el idcategorie de Deportes no aparece, devuelve NULL. No logro comprender por qué sucede esto.
Cita:
El idcategorie es esencial que pueda obtenerlo ya que para la edición de categories necesito indicar en otra consulta qué idcategorie estoy editando o borrando o para la edición de subcategories necesito indicar a qué otra categorie estoy asignando la subcategorie, mediante el idcategorie.array(2) {
[0]=>
array(6) {
["idcategorie"]=>
string(1) "1"
["iduser"]=>
string(1) "1"
["categorie"]=>
string(13) "Programación"
["idsubcategorie"]=>
string(1) "1"
["subcategorie"]=>
string(3) "PHP"
["count_subc"]=>
string(1) "4"
}
[1]=>
array(6) {
["idcategorie"]=>
NULL
["iduser"]=>
string(1) "1"
["categorie"]=>
string(7) "Deporte"
["idsubcategorie"]=>
NULL
["subcategorie"]=>
NULL
["count_subc"]=>
string(1) "0"
}
}
[0]=>
array(6) {
["idcategorie"]=>
string(1) "1"
["iduser"]=>
string(1) "1"
["categorie"]=>
string(13) "Programación"
["idsubcategorie"]=>
string(1) "1"
["subcategorie"]=>
string(3) "PHP"
["count_subc"]=>
string(1) "4"
}
[1]=>
array(6) {
["idcategorie"]=>
NULL
["iduser"]=>
string(1) "1"
["categorie"]=>
string(7) "Deporte"
["idsubcategorie"]=>
NULL
["subcategorie"]=>
NULL
["count_subc"]=>
string(1) "0"
}
}
¿Alguien puede ayudarme con esto?