Board index » delphi » DB Structure to Link a Field to Another Record in the Same Table

DB Structure to Link a Field to Another Record in the Same Table

I have records in an ADO table such as: (simplified)

key    : AutoNumber
Name : Text
keyFriend : Number

What I would like to do is use the "keyFriend" number to link to the "key"
field in the same table.  I will also need to lookup the "key" field for
setting the "keyFriend" value.

How do I set this up?  I'm not a newbie, I just need a little guidance in the
right direction.

Thanks,

-Johnnie

 

Re:DB Structure to Link a Field to Another Record in the Same Table


Quote
>key    : AutoNumber
>Name : Text
>keyFriend : Number

>What I would like to do is use the "keyFriend" number to link to the "key"
>field in the same table.  I will also need to lookup the "key" field for
>setting the "keyFriend" value.

Try this query.

Select D1.Key, D1.name,D1.KeyFriend, D2.Name as FriendName
From YourTable D1Join YourTable D2 on D1.KeyFriend = D2.Key
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:DB Structure to Link a Field to Another Record in the Same Table


Thanks - I'll give it a try.

"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:ipblgugcbgg630t5195v2r9v34jlav1g8g@4ax.com...

Quote
> >key    : AutoNumber
> >Name : Text
> >keyFriend : Number

> >What I would like to do is use the "keyFriend" number to link to the "key"
> >field in the same table.  I will also need to lookup the "key" field for
> >setting the "keyFriend" value.

> Try this query.

> Select D1.Key, D1.name,D1.KeyFriend, D2.Name as FriendName
> From YourTable D1Join YourTable D2 on D1.KeyFriend = D2.Key
> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Other Threads