| Author |
Topic |
|
chetanb3
Yak Posting Veteran
52 Posts |
Posted - 2009-02-13 : 06:39:50
|
| Hi,Is there any way that I can select many different data from different tables in one query without interfering each other?For example,Lets say that:table1 has a COUNT(data) = 8table2 has a COUNT(data) = 3table3 has a COUNT(data) = 2 I want to select All columns form each of the tables as one result set. i tried by using full join on Guid, but it retuen duplicate rows that i don't want. |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-13 : 06:47:34
|
| use distinct count(distinct data) |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2009-02-13 : 06:52:33
|
| is there a connection between the tables?How do you want the data presented?==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
chetanb3
Yak Posting Veteran
52 Posts |
Posted - 2009-02-13 : 06:59:05
|
| bklr- I want to select columns and not countnr- these tables are linked by Guid. what do you mean by DTS could you please elaborate? |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2009-02-13 : 07:00:20
|
| select t1.*, t2.*. t3.*from(select seq = row_number() over(order by guid), * from table1) t1full outer join(select seq = row_number() over(order by guid), * from table2) t2on t1.seq = t2.seqfull outer join(select seq = row_number() over(order by guid), * from table3) t3on t1.seq = t3.seq or t2.seq = t3.seqor maybeselect t1.*, t2.*. t3.*fromtable1 t1full outer jointable2 t2on t1.guid = t2.guidfull outer jointable3 t3on t1.guid = t3.guid or t2.guid = t3.guid==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-13 : 07:05:22
|
quote: Originally posted by chetanb3 Hi,Is there any way that I can select many different data from different tables in one query without interfering each other?For example,Lets say that:table1 has a COUNT(data) = 8table2 has a COUNT(data) = 3table3 has a COUNT(data) = 2 I want to select All columns form each of the tables as one result set. i tried by using full join on Guid, but it retuen duplicate rows that i don't want.
do you mean merging data as rows ir columns? |
 |
|
|
chetanb3
Yak Posting Veteran
52 Posts |
Posted - 2009-02-13 : 08:49:27
|
| not exactly that |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-13 : 08:59:12
|
| then show what you want by means of some sample data |
 |
|
|
chetanb3
Yak Posting Veteran
52 Posts |
Posted - 2009-02-18 : 08:37:49
|
| Thanks nr your solution works for me. |
 |
|
|
|