MySQL Forums
Forum List  »  New in 4.1: Subqueries

Re: self-joined update query, perhaps via subquery
Posted by: Raphael Thomas
Date: March 08, 2008 04:00AM

I know this is an old thread but I used this query to make it work on MySQL

UPDATE Tree T
INNER JOIN Tree P
ON (T.ParentNode = P.Node)
SET T.depth = P.Depth + 1 , T.Lineage = CONCAT(P.Lineage, Ltrim(T.ParentNode) , '/')
WHERE P.Depth >= 0
AND P.Lineage Is Not Null
AND T.Depth Is Null;

The only problem is that I didn't know how to make it loop in MySQL.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: self-joined update query, perhaps via subquery
2960
March 08, 2008 04:00AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.