View previous topic :: View next topic |
Author |
Message |
sonika2008 Beginner
Joined: 17 Aug 2007 Posts: 20 Topics: 9
|
Posted: Wed Sep 12, 2007 12:11 pm Post subject: how to concatenate two rows in single row? |
|
|
I have a SQL statement that fetches ID, SR.No, place information.
like this:-
ID Sr. No Place
123 x abc
x def I want that if the Sr.No is same , than palce information display in one row
like this:-
ID Sr. No Place
123 x abc def
Is there any way to concatenate the two lines become one? |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Sep 12, 2007 12:23 pm Post subject: |
|
|
sonika2008,
show us your sql as to how you are getting the rows in that fashion
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
viswanathan Beginner
Joined: 17 Jan 2006 Posts: 26 Topics: 13
|
Posted: Thu Sep 13, 2007 1:16 pm Post subject: |
|
|
Hi Sonika,
Please try this
select a.id, a.srno,a.place,b.fieldname from table1 a, table2 b
where a.srno = b.srno
If my understanding is wrong..please provide us more info in this regard.
-Vishwa |
|
Back to top |
|
 |
sriramla Beginner
Joined: 22 Feb 2003 Posts: 74 Topics: 1
|
Posted: Thu Sep 13, 2007 2:16 pm Post subject: |
|
|
Viswanathan, your query would result in duplicates. If there are 2 rows with same id, the poster want to combine them into a single row. But the join you have would give 4 rows (2 * 2). |
|
Back to top |
|
 |
A_programmer Beginner
Joined: 15 Oct 2007 Posts: 2 Topics: 0 Location: USA
|
Posted: Wed Oct 31, 2007 7:44 am Post subject: |
|
|
What about if there are multiple rows with the same Sr. No. ?
How can you dynamically add columns ???? _________________ Its not necessary to change. Survival is not mandatory. |
|
Back to top |
|
 |
|
|