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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex SQL!!!

Status
Not open for further replies.

job1

Technical User
Mar 12, 2004
26
US
Hi

I have two tables

cd table
---------------
cd
ID
Desc

Area table
-----------
Parent
Child

2. To make work easier I am creating a Temp table created with fields lets say temp
cd
id
descr

3. Then loading the data to cd,id,descr from cd table into the new table temp
insert into temp
(
cd,
id,
descr
)select
distinct cd,
id,
descr
from cd

4. Select from the area table and temp table,the parent,temp.id,test_temp.desc where temp.cd equals to
area.child.
select area.parent,temp.id, temp.desc from temp, area
where temp.bu = area.child
Ex: 210(cd)
200(parent).

5. Now the descr and ID of 200(cd) is inserted into test_temp.

6.Repeat steps 3 & 4 till pf_bu reaches 100.

Please let me know if I am not clear.

-TIA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top