Click to See Complete Forum and Search --> : Sql query problem


Vinod S
May 18th, 2004, 06:37 AM
Table 1
ENTRYCODE
DESCRIPTION

Table 2
GIVERCODE (Table1.ENTRYCODE)
RECVRCODE (Table1.ENTRYCODE)
AMOUNT
TRANSACTIONDATE

Table1 have these values
1 AAAAA
2 BBBBB
3 CCCCC
4 DDDDD

Table2 have these values
1 2 25000
2 3 10000
3 4 23000
4 null 10000

I WANT TO get the below result TO A RECORDSET using minimum sql statments(preferrably single)
AAAAA BBBBB 25000
BBBBB CCCCC 10000
CCCCC DDDDD 23000
DDDDD null 10000

can anybody help me out in this

Gabriel Fleseriu
May 18th, 2004, 12:13 PM
Basically it goes like this (not tested)

select t1a.description, t1b.description, t2.amount
from table_1 t1a, table_1 t1b, table_2 t2
where t1a.entrycode = t2.givercode and
t2a.entrycode(+) = t2.recvrcode;


Depending on what DB you are using, you will need to make a "recordset" out of the select statement.