This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes SQL Recursion Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SQL Recursion Question" Watch "SQL Recursion Question" New topic

SQL Recursion Question

Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
I could use some help figuring out the sql for a problem. Currently, there are 2 tables:
Domain, which has columns domainID, and parentDomainID. ParentDomainID references another Domain record.
EndUser, which has a column parentDomainID.

I have a procedure where I am looping over domainIDs (variable @currentDomainID). I need to do now is update all EndUser records that are in the currentDomainID or where the any parent of the endUser parentDomainID is the @parentDomainID.

In pseudocode what I need to do is this:

Any help would be appreciated.
It is sorta covered in the JavaRanch Style Guide.
subject: SQL Recursion Question
jQuery in Action, 3rd edition