torturedmind
Programmer
hi all. been a while since the last time i visited this awesome forum.
anyways, i've got a scenario here...
[tt]table1
======
lot_code ref_lot1 ref_lot2 ref_lot3
AAAAAAAA 11111111
BBBBBBBB 22222222 33333333 44444444
CCCCCCCC 55555555 66666666
DDDDDDDD 77777777 88888888
EEEEEEEE 99999999 00000000
table2
======
ref_lot qty_issued issued_date
11111111 854 06/01/2010
22222222 361 06/01/2010
33333333 1925 06/05/2010
44444444 682 06/07/2010
55555555 736 06/07/2010
66666666 557 06/08/2010
77777777 1188 06/09/2010
88888888 991 06/10/2010
99999999 715 06/10/2010
00000000 981 06/11/2010
[/tt]
i need the output to be like this...
[tt]
table3
======
lot_code ref_lot1 issqty1 issd1 ref_lot2 issqty2 issd2 ref_lot3 issqty3 issd3
--------------------------------------------------------------------------------------------------------------
AAAAAAAA 11111111 854 06/01/2010
BBBBBBBB 22222222 361 06/01/2010 33333333 1925 06/05/2010 44444444 682
CCCCCCCC 55555555 736 06/07/2010 66666666 557 06/08/2010
DDDDDDDD 77777777 1188 06/09/2010 88888888 991 06/10/2010
EEEEEEEE 99999999 715 06/10/2010 00000000 981 06/11/2010
[/tt]
my question is, can this be done using select statement only? if this can be, then how? i tried...
problem is, those records with blank ref_lots in table1 extracts record from table2 even if their ref_lots were not equal or even empty. care to give me a hand here, anyone?
kilroy![[knight] [knight] [knight]](/data/assets/smilies/knight.gif)
philippines
"Once a king, always a king. But being a knight is more than enough."
anyways, i've got a scenario here...
[tt]table1
======
lot_code ref_lot1 ref_lot2 ref_lot3
AAAAAAAA 11111111
BBBBBBBB 22222222 33333333 44444444
CCCCCCCC 55555555 66666666
DDDDDDDD 77777777 88888888
EEEEEEEE 99999999 00000000
table2
======
ref_lot qty_issued issued_date
11111111 854 06/01/2010
22222222 361 06/01/2010
33333333 1925 06/05/2010
44444444 682 06/07/2010
55555555 736 06/07/2010
66666666 557 06/08/2010
77777777 1188 06/09/2010
88888888 991 06/10/2010
99999999 715 06/10/2010
00000000 981 06/11/2010
[/tt]
i need the output to be like this...
[tt]
table3
======
lot_code ref_lot1 issqty1 issd1 ref_lot2 issqty2 issd2 ref_lot3 issqty3 issd3
--------------------------------------------------------------------------------------------------------------
AAAAAAAA 11111111 854 06/01/2010
BBBBBBBB 22222222 361 06/01/2010 33333333 1925 06/05/2010 44444444 682
CCCCCCCC 55555555 736 06/07/2010 66666666 557 06/08/2010
DDDDDDDD 77777777 1188 06/09/2010 88888888 991 06/10/2010
EEEEEEEE 99999999 715 06/10/2010 00000000 981 06/11/2010
[/tt]
my question is, can this be done using select statement only? if this can be, then how? i tried...
Code:
select table1.lot_code, ;
table2.ref_lot as ref_lot1, ;
table2.qty_issued as issqty1, ;
table2.issued_date as issd1, ;
table1.ref_lot2, ;
table1.ref_lot3 ;
from table1 ;
left outer join table2 ;
on table1.ref_lot1 = table2.ref_lot ;
into cursor table3a
select table3a.lot_code, ;
table3a.ref_lot as ref_lot1, ;
table3a.issqty1, ;
table3a.issd1, ;
table3a.ref_lot2, ;
table2.qty_issued as issqty2, ;
table2.issued_date as issd2, ;
table3a.ref_lot3 ;
from table3a ;
left outer join table2 ;
on table3a.ref_lot2 = table2.ref_lot ;
into cursor table3b
select table3b.lot_code, ;
table3b.ref_lot as ref_lot1, ;
table3b.issqty1, ;
table3b.issd1, ;
table3b.ref_lot2, ;
table3b.issqty2, ;
table3b.issd2, ;
table3b.ref_lot3 ;
table2.qty_issued as issqty3, ;
table2.issued_date as issd3, ;
from table3b ;
left outer join table2 ;
on table3b.ref_lot3 = table2.ref_lot ;
into cursor table3_final
problem is, those records with blank ref_lots in table1 extracts record from table2 even if their ref_lots were not equal or even empty. care to give me a hand here, anyone?
kilroy
![[knight] [knight] [knight]](/data/assets/smilies/knight.gif)
philippines
"Once a king, always a king. But being a knight is more than enough."