Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Having a relationship with oneself
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ask SQLTeam Question

0 Posts

Posted - 10/31/2003 :  07:57:30  Show Profile  Visit AskSQLTeam's Homepage
Zimon writes "I have a table of items as follows:
Item_ID Item_Name
1 Pish
2 Posh
3 Pash

I have a table of associations as follows:
Item1_ID Item2_ID
1 2
2 3

I need the output:
First_Item Second_Item
Pish Posh
Posh Pash

But after days of trying and internet searching I have no idea how to structure the SQLServer query. Please can you help or confirm that this is an imposibility.


Most Valuable Yak

15732 Posts

Posted - 10/31/2003 :  07:59:02  Show Profile  Visit robvolk's Homepage
<wiping away tears of laughter>

Try this:

</wiping away tears of laughter>

Although you can probably get away with:

SELECT A.Item_Name, B.Item_Name
FROM myTable A INNER JOIN Association C ON A.Item1_ID
INNER JOIN myTable B ON C.Item2_ID=B.Item_ID

And if you REALLY meant what the title states, then perhaps this is what you need:

Edited by - robvolk on 10/31/2003 08:01:20
Go to Top of Page

Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 10/31/2003 :  08:10:56  Show Profile  Visit Merkin's Homepage
I knew you were gonna have some fun with that one when I saw it in the queue

Go to Top of Page

Starting Member

31 Posts

Posted - 10/31/2003 :  08:12:40  Show Profile
In addition to Rob's suggestion, this might also be helpful
Go to Top of Page

Dr. Cross Join

7423 Posts

Posted - 10/31/2003 :  08:14:02  Show Profile  Visit jsmith8858's Homepage
LOL .... almost fell out of my chair ....

- Jeff
Go to Top of Page

Flowing Fount of Yak Knowledge

1632 Posts

Posted - 10/31/2003 :  08:14:06  Show Profile
Spilled coffee on my laptop

Edited by - ehorn on 10/31/2003 08:14:46
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000