baanprog
2nd December 2004, 07:31
Hi,

I have two tables which have the same index. They both have to be printed in the same detail in the report. I want to achieve this using only select statements.

Group returns cross product of the two tables when I select both the tables.

I cannot select one table and then the other since both have more than one record.

if it using counting records and arrays, I know the solution.

Can anyone suggest how this can be achieved just using select statements, I will appreciate it.

table tsmmm905 index 1 = tsmmm905.recd, tsmmm905.redt, tsmmm905.shed, tsmmm905.shift, tsmmm905.sno

table timmm921 index 1 = tsmmm921.recd, tsmmm921.redt, tsmmm921.shed, tsmmm921.shift, tsmmm921.sno

Thanks

csecgn
2nd December 2004, 13:22
What about refers to? If you don't have combined fields, you can use

select table.*, table2.*
from table1, table2
where <your condition>
and {table1.x, table1.y ...} refers to table2 [unref clear]

Regards
csecgn

vahdani
2nd December 2004, 13:52
Hi,

your requirement is not very clear. You could eventually use the follwing slight of hand trick:
1- Design your report for the first table only.
2- In your session use a script similar the follwing:
| first read data from table1
select *
from table1
where ....
selectdo
rprt_send()
endslect

| now read table2 and pretend as though this data was
| coming from table1 !!!
select *
from table2
where ....
selectdo
table1.field1 = table2.field1
table1.field2 = table2.field2
.
.
.
rprt_send()
endselect

3- Use proper sorting on your input fields in the report. The detail will now be printed according to field content and not according to which table they come from! :cool: