Click here to Skip to main content
16,004,893 members
Home / Discussions / Database
   

Database

 
GeneralADO: Delete record fails for dBASE file Pin
10-Jan-02 2:46
suss10-Jan-02 2:46 
GeneralCRecordset::Edit() Pin
3-Jan-02 4:07
suss3-Jan-02 4:07 
GeneralRe: CRecordset::Edit() Pin
Rashid Thadha5-Jan-02 12:30
Rashid Thadha5-Jan-02 12:30 
General10$ Reward - Honestly Pin
Las B29-Dec-01 12:31
Las B29-Dec-01 12:31 
GeneralRe: 10$ Reward - Honestly Pin
AndyG30-Dec-01 10:10
AndyG30-Dec-01 10:10 
QuestionData Access Pages for SQL Server? Pin
23-Dec-01 19:02
suss23-Dec-01 19:02 
GeneralA problem about converting data in ADODB.Recordset object(supplied by COM DLL) into DataStore in PowerBuilder environment. Pin
22-Dec-01 21:02
suss22-Dec-01 21:02 
Generalsql query problem Pin
16-Dec-01 15:27
suss16-Dec-01 15:27 
Hi,

i have a database with tables person,position and player.

Person Table Definition:
person_id -> unique id of the person
person_first_name -> person first name
person.person_last_name -> person last name

For instance:
1,John,Scotch
2,Paul,Whisky

Position Table Definition:
position_id -> unique position id
position_short -> short description of the position
position_long -> description of the position

For instance:
1,QB,Quarterback
2,WR,Wide Receiver
3,TE,Tight End
4,DE,Defensive End
5,DT,Defensive Tackle
6,CB,Cornerback

Player Table Definition:
player_id -> unique player id
player_person_id -> foreign key pointing to Person table
player_offense_position_id -> foreign key pointing to Position table
player_defense_position_id-> foreign key pointing to Position table

For instance:
1,1,3,4
2,2,2,6

Now i want to display the info like this:

Name Last Name Off Posit. Def Posit.
John Scotch Tight End Defensive End
Paul Whisky Wide Receiver Cornerback

My query succeeds when i only use both id's for the
position instead of the descriptive form:
select person.person_first_name, person.person_last_name,
player.player_offense_position_id,
player.player_defense_position_id
from person, player
where
player.player_person_id = person.person_id

It also works when i change 1 of the id's to the long description:
select person.person_first_name, person.person_last_name,
position.position_long,
player.player_defense_position_id
from person, player, position
where
player.player_person_id = person.person_id
and player.player_offense_position_id = position.position_id

But then only the foreign key of the offensive position is resolved.

When i try to have both offense and defensive id's as descriptions,
like this, it doesn't work:
select person.person_first_name, person.person_last_name,
position.position_long,
position.position_long,
from person, player, position
where
player.player_person_id = person.person_id
and player.player_offense_position_id = position.position_id
and player.player_defense_position_id = position.position_id

How can i replace both the offensive position id and the defensive
position id with their respective entries from the position table?
(i.e. resolve the foreign key and use the long description)

Also, is there a reference to the SQL syntax anywhere?

As you can see, i'm rusty on the sql part Smile | :)

BK
GeneralRe: sql query problem Pin
AndyG30-Dec-01 10:45
AndyG30-Dec-01 10:45 
General[ADO] leaking memory when opening/closing connection every minute Pin
the_saw_is_the_law13-Dec-01 3:13
the_saw_is_the_law13-Dec-01 3:13 
GeneralRe: [ADO] leaking memory when opening/closing connection every minute Pin
Mike Osbahr13-Dec-01 10:08
Mike Osbahr13-Dec-01 10:08 
GeneralRe: [ADO] leaking memory when opening/closing connection every minute Pin
the_saw_is_the_law15-Dec-01 7:40
the_saw_is_the_law15-Dec-01 7:40 
GeneralRe: [ADO] leaking memory when opening/closing connection every minute Pin
chris foote17-Dec-01 15:02
chris foote17-Dec-01 15:02 
QuestionADO with Jetengine very slow? Pin
zack12-Dec-01 4:29
zack12-Dec-01 4:29 
AnswerRe: ADO with Jetengine very slow? Pin
Thomas Ascher8-Jan-02 1:00
Thomas Ascher8-Jan-02 1:00 
GeneralSQL Server connection sharing Pin
Nick Blumhardt11-Dec-01 15:33
Nick Blumhardt11-Dec-01 15:33 
GeneralRe: SQL Server connection sharing Pin
Rashid Thadha12-Dec-01 3:04
Rashid Thadha12-Dec-01 3:04 
GeneralRe: SQL Server connection sharing Pin
16-Dec-01 18:33
suss16-Dec-01 18:33 
GeneralGetting (OLE-DB) row handle Pin
Selahattin ERDEN10-Dec-01 12:06
Selahattin ERDEN10-Dec-01 12:06 
GeneralHelp!. Access & ODBC & Left Outer Joins Pin
Fred C V10-Dec-01 6:38
Fred C V10-Dec-01 6:38 
GeneralRe: Help!. Access & ODBC & Left Outer Joins Pin
AdamF4-Jan-02 5:24
AdamF4-Jan-02 5:24 
GeneralRe: Help!. Access & ODBC & Left Outer Joins Pin
Fred C V16-Jan-02 19:43
Fred C V16-Jan-02 19:43 
GeneralMySQL HELP! Pin
Bill Gates Antimatter Particle10-Dec-01 1:44
Bill Gates Antimatter Particle10-Dec-01 1:44 
GeneralRetrieval of data from mulit table from SQL server and load into datagrid Pin
blueei5-Dec-01 21:44
blueei5-Dec-01 21:44 
GeneralAllow Zero Lenght and SqlAPI Pin
4-Dec-01 6:20
suss4-Dec-01 6:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.