I have very simple table
I want to receive table with i,id and text column like 67->304->303->302->301->300->299
I don't understand What wrong in my CTE?
WITH RECURSIVE
CTE (CTE_i, CTE_Id, CTE_ParentID, CTE_ParentI, Arrow) AS
(
Select i, Id, NULL, NULL,'.' FROM DockerImage where ParentId =''
UNION ALL
Select DockerImage.I, DockerImage.Id, DockerImage.ParentId, CTE_i , CONCAT (CTE.Arrow, '->', DockerImage.I) FROM CTE
join DockerImage on CTE_ParentId=DockerImage.id
)
SELECT * FROM CTE;
Result of this SQL is wrong and I have no recursion.
I think your join is backwards. The initial select has blank ParentID, so the join needs to be from cte.id to DockerImage.ParentID.
JOIN DockerImage ON CTE.CTE_id = DockerImage.Parentid
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply