Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a sql query like this?

Status
Not open for further replies.

thorsson

Programmer
May 30, 2007
1
SE
I need to be able to join table a on table b multiple times like in the code example below. If I was working against a SQL-server i could make a sp but this is a AS/400-machine I have to work against.
Code:
select oroordnr,b.ufutftxt,c.ufutftxt,d.ufutftxt,e.ufutftxt,f.ufutft 
xt,orluffrg,ohoordnr,ohlevnmn,oholwelu from ohorhuvp as o            
inner join ororradp as a on o.ohoordnr = a.oroordnr                  
inner join ufufregp as b on a.orutfsrt = b.ufutfkod and b.ufutftyp = 
'SRT'                                                                
inner join ufufregp as c on a.orutffrt = c.ufutfkod and c.ufutftyp = 
'FRT'                                                                
inner join ufufregp as d on a.orutfltp = d.ufutfkod and d.ufutftyp = 
'LTP'                                                                
inner join ufufregp as e on a.orutfluf = e.ufutfkod and e.ufutftyp = 
'LUF'                                                                
inner join ufufregp as f on a.orutfvar = f.ufutfkod and f.ufutftyp = 
'VAR'                                                                
where o.oholwelu =200732

Thanks
 
Post your software version. First thing any tech support person would askyou (well, perhaps 2nd to your credit card number).

In Cr 9 and above just paste the SQL into the Add Command which is listed just below your data source.

-k

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top