Join Parent Column

158
July 29, 2018, at 06:50 AM

Hi I have a table named Orders that has a parent column which refer to a previous related order.

order_id    parent_order_id
2           NULL
3           2
5           3
6           5

I need a query that puts the last order_id against the first one considering the fact that not all orders are like this, some have 2 parents, some 1 and some may have no parents at all. So the number of joins is unknown.

The desirable result for the example above is as follows:

order_id    parent_order_id
6           2

Is it possible? Thanks.

Rent Charter Buses Company
READ ALSO
opendl failed in alljoynlib in android

opendl failed in alljoynlib in android

I have an alljoyn library in my project to pair android devices for a voting appIn old devices the app runs properly but in new devices it stops when it is starting to run

164
Spring - Hibernate: Unable to Save object data to table with HibernateTemplate

Spring - Hibernate: Unable to Save object data to table with HibernateTemplate

I have looked throughout stackoverflow and I can not seem to find an answer to my query pertaining to saving Created Objects to a Database Table (MySQL) using the HibernateTemplateI am using Hibernate 5 and the latest iteration of Spring 5

166
Jersey GET a JSON of tree format

Jersey GET a JSON of tree format

So, you have some instances of class Library and some instances of class Book in a one to many relation, all of them persisted through JPANow, you retrieve the List of Books that belongs to a certain Library through its unique library ID and you want to return...

179
Node.js library for fingerprint scanning

Node.js library for fingerprint scanning

I am building an application using nodejs and angular

291