By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,822 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,822 IT Pros & Developers. It's quick & easy.

sql syntax for joining two tables in query

P: 3
Here is my problem: I have two tables tied together by ID#

Table: customer

FName..LName.......ID#.......LeaderID#

Jill.........Jones.........1111.......345
Mark......Placid........2222.......543
Joe........Smith...........345.......849
Phil........Simmon.......543.......987


Table: rank

ID#........rank

1111.......2
2222.......3
345.........5
543.........5

I need to display the persons name and leaders name where the person
has a Rank >=3 and their leader has to have a Rank >=3
So in this case i need the results to be:

Mark Placid 2222 Phil simmon 543
May 25 '07 #1
Share this Question
Share on Google+
2 Replies

Rabbit
Expert Mod 10K+
P: 12,441
Here is my problem: I have two tables tied together by ID#

Table: customer

FName..LName.......ID#.......LeaderID#

Jill.........Jones.........1111.......345
Mark......Placid........2222.......543
Joe........Smith...........345.......849
Phil........Simmon.......543.......987


Table: rank

ID#........rank

1111.......2
2222.......3
345.........5
543.........5

I need to display the persons name and leaders name where the person
has a Rank >=3 and their leader has to have a Rank >=3
So in this case i need the results to be:

Mark Placid 2222 Phil simmon 543
You would need to INNER JOIN two copies of the rank table to ID# and LeaderID#.
May 25 '07 #2

NeoPa
Expert Mod 15k+
P: 31,770
You would need to INNER JOIN two copies of the rank table to ID# and LeaderID#.
You probably already know, but you'd need to use the 'AS' keyword on the second copy to differentiate it from the first :
Expand|Select|Wrap|Line Numbers
  1. ...
  2. ... INNER JOIN Rank AS LdrRank ON ...
  3. ...
Please let us know how you get on with this.
May 26 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.