Navegar Por
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`Cant` > 0 order by node.lft, node.nombre' at line 38 WITH RECURSIVE
CategoryHierarchy AS (
SELECT
c.URL,
c.ID,
c.Abreviacion,
c.Nombre,
c.Padre,
c.CatSat,
c.Sucursal,
1 AS Level,
c.Nombre as Path2,
c.Lft
FROM categoria c
WHERE c.Padre = '' and c.sucursal = 1891
UNION ALL
SELECT
c.URL,
c.ID,
c.Abreviacion,
c.Nombre,
c.Padre,
c.CatSat,
c.Sucursal,
ch.Level + 1 AS Level,
CONCAT(ch.Path2, ' - ', c.Nombre) AS Path2,
c.Lft
FROM categoria c
INNER JOIN CategoryHierarchy ch ON c.Padre = ch.ID
WHERE c.Sucursal = ch.Sucursal and c.sucursal = 1891
)SELECT CONCAT(REPEAT('---', Level - 1), Nombre) AS Nombre,
node.ID, node.Url ,(select count(*) from producto_categoria pc, producto p, producto_variante pv where p.id = pv.producto and p.sucursal = pv.sucursal and
pc.id_producto = p.id and pc.sucursal = p.sucursal and pv.ecommerce = 'SI' and pc.id_categoria = node.id and pc.sucursal = node.sucursal and pv.Status in ('ACTI', 'SOLO')) as 'Cant'
FROM CategoryHierarchy as node
WHERE Sucursal = 1891HAVING `Cant` > 0 order by node.lft, node.nombre
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'node.ID, node.Url , (select count(*) from producto_categoria pc, producto p, pro' at line 36 WITH RECURSIVE
CategoryHierarchy AS (
SELECT
c.URL,
c.ID,
c.Abreviacion,
c.Nombre,
c.Padre,
c.CatSat,
c.Sucursal,
1 AS Level,
c.Nombre as Path2,
c.Lft
FROM categoria c
WHERE c.Padre = '' and c.sucursal = 1891
UNION ALL
SELECT
c.URL,
c.ID,
c.Abreviacion,
c.Nombre,
c.Padre,
c.CatSat,
c.Sucursal,
ch.Level + 1 AS Level,
CONCAT(ch.Path2, ' - ', c.Nombre) AS Path2,
c.Lft
FROM categoria c
INNER JOIN CategoryHierarchy ch ON c.Padre = ch.ID
WHERE c.Sucursal = ch.Sucursal and c.sucursal = 1891
)SELECT node.Nombre AS Nombre, node.ID, node.Url , (select count(*) from producto_categoria pc, producto p, producto_variante pv where p.id = pv.producto and p.sucursal = pv.sucursal and
pc.id_producto = p.id and pc.sucursal = p.sucursal and pv.ecommerce = 'SI' and pc.id_categoria = node.id and pc.sucursal = node.sucursal) as 'Cant'
node.ID, node.Url , (select count(*) from producto_categoria pc, producto p, producto_variante pv where p.id = pv.producto and p.sucursal = pv.sucursal and
pc.id_producto = p.id and pc.sucursal = p.sucursal and pv.ecommerce = 'SI' and pc.id_categoria = node.id and pc.sucursal = node.sucursal) as 'Cant'
FROM CategoryHierarchy as node
WHERE Sucursal = 1891 AND node.Padre = 105 having `Cant` > 0 order by node.lft, node.nombre