MySQL Forums
Forum List  »  General

Re: LEFT JOIN - loosing a line from LEFT table selection
Posted by: Libor Dub
Date: April 28, 2014 10:18AM

Hello,

I am sorry for the very late reply. BTW, your formatting is good, I was surprised about the mess the forum created in my post...

The problem is simple. This is what is in the database:
359
|---822
|---875
..|---859
..|---834
..|---846
..|---810

There is an "Item" table and "ParentItems" table, where there's a definition of a ParentItem for all items, which are not TOP-level items.

The query should display all the items and parents (except the top-level item):
Item... Parentitem
822..... 359
875..... 359
859..... 875
834..... 875
846..... 875
810..... 875

But instead, I get this:
Item ... Parentitem
822..... 359
859..... 875
834..... 875
846..... 875
810..... 875

If I remove 2nd level JOINs, I get correct 1st level items:
Item ... Parentitem
822..... 359
875..... 359

...which is very strange - why the JOINs kicked out Item "875" if it is displayed, when only part of the query is executed??

Basically, what I am trying to do is select Items recursively to 4th level out of the top-level item (only simple 1 way top-down recursion). There's no good support of recursive selection in MySQL, so this is a work around.

I hope I explained it better.

Libor

Options: ReplyQuote




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.