User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 373,479 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,936 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 830 | Replies: 5
Reply
Join Date: May 2007
Posts: 4
Reputation: rado is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
rado rado is offline Offline
Newbie Poster

cross data please heslp

  #1  
May 16th, 2007
i have table
(id1,id2)
1.row [1,2]
2.row [2,1]
3.row [3,4]
4.row [4,3]
5.row [5,6]
6.row [6,5]

i want to get result:

1.row [1,2]
3.row [3,4]
5.row [5,6]

or

2.row [2,1]
4.row [4,3]
6.row [6,5]

i try anithing, (but not temporarry table), to eliminate cross data, but ... , can you help please, how i get my result?

Rado, thanx very much.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2007
Location: Warrington, England
Posts: 31
Reputation: SkinHead is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
SkinHead SkinHead is offline Offline
Light Poster

Re: cross data please heslp

  #2  
May 17th, 2007
It's Not Too Clear What You Want.

1. A Query That Gives You Rows Where id1<id2 ?

2. A Query That Gives You Rows Where id2<id1 ?

You Mentioned Temporary Tables, So Either You're Making Things Too Complicated Or I'm Completely Missing The Point !
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation: campkev is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: cross data please heslp

  #3  
May 21st, 2007
select distinct case when id1<id2 then id1 else id2 end, case when id1<id2 then id2 else id1 end from tablename
Reply With Quote  
Join Date: Mar 2007
Posts: 28
Reputation: cfAllie is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cfAllie cfAllie is offline Offline
Light Poster

Re: cross data please heslp

  #4  
May 21st, 2007
select t1.*
from theTable t1 join theTable t2
on t1.id2 = t2.id1 and t1.id1 < t2.id1
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation: campkev is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: cross data please heslp

  #5  
May 22nd, 2007
Originally Posted by cfAllie View Post
select t1.*
from theTable t1 join theTable t2
on t1.id2 = t2.id1 and t1.id1 < t2.id1

I don't have time to test this, but i don't think that this will work. This won't show any id1's that don't have a matching id2 or any id2's that don't have a matching one
Reply With Quote  
Join Date: Mar 2007
Posts: 28
Reputation: cfAllie is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cfAllie cfAllie is offline Offline
Light Poster

Re: cross data please heslp

  #6  
May 22nd, 2007
It probably wouldn't. It would give them only

i want to get result:

1.row [1,2]
3.row [3,4]
5.row [5,6]
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MS SQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 5:38 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC