MYSQL code for recursive select

Please create the MYSQL code to combine 3 tables recursively so that we can go at least 1,000 levels deep.

Essentially, we’re expanding the Bill of Materials. So, the ProdOrderRes table has the first level materials required to build the order. Then we check the Bill of materials using MAST and STPO over and over until we get to the end of the BOM and there are no more materials, basically down to the last screw.

I would do this by doing select loops on a table and then appending to that table. But, you can do it however it works. You will end up with a long table that has the order, the material(matnr), plant(werks), the quantity needed (bdmng), and BOM level.

I can string several sql statements distinctly if needed.

The code will have to compile in my Mysql system.

I would write this in ABAP as follows, but I don’t know SQL well enough.

Select *

Into table t_header

from ProdOrderRes.

***first lines are all level one

loop at t_header assigning <head>.

<head>-level = ‘1’.


loop at t_header assigning <head>.

If <head>-matnr is not initial.

Sel_matnr = <head>-matnr.


***this is only for the level one materials.

Sel_matnr = <head>-plnbez.


Select stlnr

into bom_stlnr

from mast

where matnr = sel_matnr

and werks = <head>-werks.

Select idnrk pswrk menge

Into next_matnr, next_werks, next_menge

From stop

Where stlnr = bom_stlnr.

Wa-aufnr = <head>-aufnr.

Wa-auart = <head>-auart.

Wa-autyp = <head>-autyp.

Wa-werks = next_werks.

Wa-matnr = next_matnr.

Wa-gamng = next_menge.

Wa-level = <head>-level + 1.

Append wa to t_head.




Compétences : MySQL

en voir plus : select price service charge select code mysql, java code read excel write mysql, can write code paging php mysql table, dynamic form select ajax php mysql, chained select menu database mysql, apriori code mysql, city zip code mysql, select form php mysql, simple reservation code mysql php, html code mysql database, photo gallery image show php source code mysql, drop select tables php mysql, ajax code mysql read, write mysql processing, zip code search php mysql database, vbnet code uploading file mysql table, zip code distance search mysql, java programs read excel sheets write mysql database, write mysql query, write mysql database

Concernant l'employeur :
( 3 commentaires ) Woodland Hills, United States

Nº du projet : #12630540

Décerné à:


Hi there.. I have read your project details completely and willing to do it for you... Check my recent reviews for our quality work on on time delivery :) Please inbox and we can discuss about project and I will re Plus

%selectedBids___i_sum_sub_4% %project_currencyDetails_sign_sub_5% USD en 1 jour
(10 Commentaires)