Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Maharisi
Starting Member
19 Posts |
Posted - 2008-01-11 : 03:50:36
|
How can I join row from first table and row from second table to only one row with only one SELECT statement.Thanks so muchmaharisi |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-11 : 04:24:21
|
on what condition? plzz give structure of tables and expected output. |
 |
|
Maharisi
Starting Member
19 Posts |
Posted - 2008-01-11 : 04:32:43
|
OK I have only one TABLE for example:ID Name1 John2 TomI need join these two rows to only one row looks likeName1 Name2John Tombut only one SELECT statement and I need use two different WHERE conditions ID |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-11 : 04:50:18
|
quote: Originally posted by Maharisi OK I have only one TABLE for example:ID Name1 John2 TomI need join these two rows to only one row looks likeName1 Name2John Tombut only one SELECT statement and I need use two different WHERE conditions ID
If you have only two rows thenselectmax(case when id=1 then name end) as Name1 ,max(case when id=2 then name end) as Name2 from yourTableMadhivananFailing to plan is Planning to fail |
 |
|
Maharisi
Starting Member
19 Posts |
Posted - 2008-01-11 : 05:02:34
|
I dont have only two rows.Thanks Madhivanan |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-11 : 05:14:17
|
Try this:-SELECT t1.Name AS 'Name1',t2.Name AS 'Name2'FROM Table t1CROSS JOIN Table t2WHERE t1.ID = @ID1AND t2.ID=@ID2@ID1 & @ID2 are your reqd IDs to be passed to query |
 |
|
Maharisi
Starting Member
19 Posts |
Posted - 2008-01-11 : 07:49:38
|
thanks a lot |
 |
|
|
|
|