SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
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  

AskSQLTeam
Ask SQLTeam Question

USA
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.

Zimon"

robvolk
Most Valuable Yak

USA
15659 Posts

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

Try this:

http://www.sqlteam.com/item.asp?ItemID=8866

</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:

http://www.amazon.com/exec/obidos/tg/detail/-/0517886073/102-8441179-3137755?v=glance

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

Merkin
Funky Drop Bear Fearing SQL Dude!

Australia
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


Damian
Go to Top of Page

homam
Starting Member

31 Posts

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

http://www.amazon.com/exec/obidos/ASIN/0380806347/
Go to Top of Page

jsmith8858
Dr. Cross Join

USA
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

ehorn
Flowing Fount of Yak Knowledge

USA
1630 Posts

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

http://www.webheights.net/lovethyself/home.htm

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.08 seconds. Powered By: Snitz Forums 2000