sql statement: join

From: Thomas Steffen <thomas.rademacher_at_nikocity.de>
Date: 8 Jan 2003 13:40:33 -0800
Message-ID: <ba63dde5.0301081340.36aeb359_at_posting.google.com>



Hallo,

a happy new year!

I have two tables:

	table A with attribute A_ID (primary key)
	table B with attribute B_ID (primary key)
		 and attribute A_ID (foreign key with A.A_ID == B.A_ID).

The relation between table A and table B is 1:n; n is VARIABLES in dependency of A_ID.

With "select A.A_ID, B.B_ID from A,B where A.A_ID == B.A_ID order by A.A_ID, B.B_ID asc"
I get the following results in cursor:

(1) A_ID1, B_ID1
(2) A_ID1, B_ID2
(3) A_ID2, B_ID3
(4) A_ID2, B_ID4
(5) A_ID2, B_ID5
(6) A_ID3, B_ID6

        ...

Now I want to get the following results in cursor:

(1) A_ID1, num1, B_ID1, B_ID2
(2) A_ID2, num2, B_ID3, B_ID4, B_ID5
(3) A_ID3, num3, B_ID6

        ...
numX is the number of of keys B_ID.

How can I reslove this problem with ONE sql satement?

Thank you for your hints, Thomas Received on Wed Jan 08 2003 - 22:40:33 CET

Original text of this message