combining 2 rows in 1
From: Alex Forkosh <aforkosh_at_dr.com>
Date: Fri, 11 Jan 2002 04:50:36 GMT
Message-ID: <wau%7.1066$Vq.14078_at_rwcrnsc53>
table: Names
name_id
first_name
last_name
table: Phones
phone_id
phone_number
table: NamesToPhones
name_id
phone_id
select n.first_name,n.last_name,p.phone_number from Names n , Phones P , NamesToPhones np where name_id = 2
and np.name_id = n.name_id
and np.phone_id = p.phone_id
John Doe 555-555-5555 222-555-5555
or any other delimiter instead of space.
Date: Fri, 11 Jan 2002 04:50:36 GMT
Message-ID: <wau%7.1066$Vq.14078_at_rwcrnsc53>
Hi.
I have 3 tables in Oracle 8i:
table: Names
name_id
first_name
last_name
table: Phones
phone_id
phone_number
table: NamesToPhones
name_id
phone_id
A person can have more than one number and A number can be assigned to more than one person.
when executing :
select n.first_name,n.last_name,p.phone_number from Names n , Phones P , NamesToPhones np where name_id = 2
and np.name_id = n.name_id
and np.phone_id = p.phone_id
returns 2 rows because John Doe has 2 phone numbers:
John Doe 555-555-5555 John Doe 222-555-5555
----------------------------
QUESTION:
is there any way to return 1 row instead of two using SQL or Oracles
functions???
Desired output:
John Doe 555-555-5555 222-555-5555
or any other delimiter instead of space.
Thanks to anyone who replies. Received on Fri Jan 11 2002 - 05:50:36 CET