MySQL Forums
Forum List  »  Quality Assurance

Need help for stange behaveour
Posted by: Rosen Ralev
Date: January 25, 2008 02:27AM

Hi :) I need help on the following problem.
I have the following table,

id name parent
1 1dno 5
2 2ve 0
5 3i 2
4 4i 1

And execute:

SELECT * , @a := id
FROM `test`
WHERE parent = @a
OR parent =0;

And I get for result:

id name parent @a := id
2 2ve 0 2
5 3i 2 5

So my question is, why I get only two results. I assumed that it would return the entire table starting with the row which parent is zero and then the next row will be with parent = 2 and then parent=5 and so on. This way I wanted to order the rows following the parent dependency.
I am not sure if this is the right way to do it, but I am puzzled by the result this query gives.
I would appreciate if some body explains to me why do I get this result.
I am testing it on MySQL 5.0.32

If there is an other way to achieve the order i desire, please tell so :)

Thank you in advance :)

Options: ReplyQuote


Subject
Views
Written By
Posted
Need help for stange behaveour
2685
January 25, 2008 02:27AM


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.