Re: SQL problem ?
Posted in 1996
> julie@research.trd.iii.org.tw (Julie Lin) writes:
> Hi,
>
> I have two tables with the following data :
>
> table 1 : c1 table 2 : c2
> --- ---
> 1 a
> 2 b
>
> How to formulate a query to get data as c1 c2 ??
> ----- -----
> 1 a
> 2 b
A select from two tables with no join and no cartesian product?
One option may be via a stored procedure:
select c1, tab2()
from table1
order by c1 <- optional
tab2 would be a stored procedure that read from table2 in a foreach loop
and returned the values from that table.
You'l get some problems if there aren't the same number of rows in table1 and table2.
The select should always read from the table with the most rows. The stored procedure
should keep returning null-values if it was called and there where no more rows
in the table it read from. A parameter may be neccesary to call it once more after
the select has finhised with anohter value to this parameter to terminate the
returning of null-values.
I haven't tested this, but it might work.
Nils.Myklebust@ccmail.telemax.no
NM-data, Aasesvei 71, 1300 Sandvika, Norway
My opinions are those of my company