Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Development
»
recursive query from multiple tables
recursive query from multiple tables
Rate Topic
Display Mode
Topic Options
Author
Message
stewsterl 80804
stewsterl 80804
Posted Monday, October 12, 2009 9:55 PM
Grasshopper
Group: General Forum Members
Last Login: Friday, March 04, 2011 11:04 AM
Points: 13,
Visits: 69
Ok you DBA Gods this one has got me to that point that I just want to say F-it I cant do it I give up.
I hope I can explain this well...
I need to create a recursive query to supply the data to a TELERIK treeview. The problem is that the data I have to play with is not in an easy format to work with.
I have three tables. WORK_ORDER, PART AND REQUIREMENT (Database is from Infor ERP VISUAL - ERP manufacturing Software)
The WORK_ORDER table can have parts and the REQUIREMENT table can also have parts. Both connect to the same part table using the Part_id. A work order can have multiple requirements with many parts. Here is the view that gives me all the data I need.
SELECT WORK_ORDER.BASE_ID, WORK_ORDER.PART_ID AS WO_PART_ID, PART_1.DESCRIPTION AS WO_DESCRIPTION, REQUIREMENT.PART_ID,
PART.DESCRIPTION
FROM WORK_ORDER INNER JOIN
PART AS PART_1 ON WORK_ORDER.PART_ID = PART_1.ID INNER JOIN
REQUIREMENT INNER JOIN
PART ON REQUIREMENT.PART_ID = PART.ID ON WORK_ORDER.BASE_ID = REQUIREMENT.WORKORDER_BASE_ID
WHERE (REQUIREMENT.STATUS = 'R')
However, I want to Traverse this data so I can create a parent child relationship or change the above query to a recursive query. NOTE almost all parents are duplicated because they also can have multiple parts and requirements.
BASE_ID WO_PART_ID WO_DESCRIPTION PART_ID DESCRIPTION
04060 30766 Truss Rod Gusset - tall 01034 Flat Bar 1/4 x 5 per inch
04061 30767 Truss Rod Gusset - short 01034 Flat Bar 1/4 x 5 per inch
04109 30420 Impeller 01037 Flat Bar 1/8 X 1 per inch
03337 28604 Gusset 01047 Round, 1/2 HR per inch
03582 28604 Gusset 01047 Round, 1/2 HR per inch
Post #801930
Dave Ballantyne
Dave Ballantyne
Posted Tuesday, October 13, 2009 2:05 AM
SSCommitted
Group: General Forum Members
Last Login: Friday, May 10, 2013 4:07 PM
Points: 1,943,
Visits: 8,227
Is this a bill of materials ?
Try this...
http://sqlblog.com/blogs/john_paul_cook/archive/2009/10/11/bill-of-materials-where-used-query.aspx
Clear Sky SQL
My Blog
Kent user group
Post #802007
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.