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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 HELP on Joining Tables

Author  Topic 

jvst
Starting Member

12 Posts

Posted - 2012-08-04 : 03:17:44
i joined 3 tables, c
C1
1 0 0 0 0 0 0 0 2 2
2 0 0 0 0 0 0 0 2 3
3 0 0 0 0 0 0 0 2 3
5 0 0 0 0 0 0 0 2 3

C2
1 3 0 0 0 0 0 0 3 2
2 3 0 0 0 0 0 0 3 2
2 5 0 0 0 0 0 0 3 3
3 5 0 0 0 0 0 0 3 2

and C3
2 3 5 0 0 0 0 0 4 2

to create a table named FISETS

create table FISETS(item1 bigint, item2 bigint, item3 bigint, nullm bigint, count bigint)

So FISETS now contains:

ITEM1 ITEM2 ITEM3 ITEM4 ITEM5 ITEM6 ITEM7 ITEM8 NULLM COUNT
1 0 0 0 0 0 0 0 2 2
2 0 0 0 0 0 0 0 2 3
3 0 0 0 0 0 0 0 2 3
5 0 0 0 0 0 0 0 2 3
1 3 0 0 0 0 0 0 3 2
2 3 0 0 0 0 0 0 3 2
2 5 0 0 0 0 0 0 3 3
3 5 0 0 0 0 0 0 3 2
2 3 5 0 0 0 0 0 4 2



Now for each of the items in the FISETS, I need to generate the non-empty subsets. In other words (without "nullm" and "count" columns, I need each row to be paired up (joined?) with the other rows so i will come up with

TITEM1 TITEM2 TITEM3 TITEM4 TITEM5 TITEM6 TITEM7 TITEM8
1 2 0 0 0 0 0 0
2 1 0 0 0 0 0 0
1 3 0 0 0 0 0 0
3 1 0 0 0 0 0 0
1 5 0 0 0 0 0 0
5 1 0 0 0 0 0 0
2 3 0 0 0 0 0 0
3 2 0 0 0 0 0 0
2 5 0 0 0 0 0 0
5 2 0 0 0 0 0 0
1 1 3 0 0 0 0 0
:
:
:
and so on and so forth..

can you join without condition? PLEASE, PLEASE HELP! Thank you..

jvst
Starting Member

12 Posts

Posted - 2012-08-04 : 03:18:48
By the way, the sequence is not important.

Go to Top of Page
   

- Advertisement -