I hope I can explain this correctly. How do I complete a select statement so if a person's ID is at a specific location and other locations (if any) then retrieve the locations that I specify and the other locations.
TABLE A
ID term crse_nbr
1 0094 1
1 0094 5
1 0094 6
2 0094 1
2 0094 7
3 0094 8
3 0094 9
4 0096 10
TABLE B
term crse_nbr session title
0094 1 1 test
0094 5 1 test1
0094 6 1 test2
0094 7 1 test3
0094 8 1 test4
0094 9 1 test5
0096 10 2 test6
term crse_nbr session location
0094 1 1 PC
0094 5 1 ON
0094 6 1 DC
0094 7 1 BT
0094 8 1 BT
0094 9 1 SD
0096 10 2 HN
What I have so far:
select TABLE A.ID, TABLE B.term, TABLE B.title, TABLE C.location from
TABLE A,
TABLE B,
TABLE C,
where
TABLE A.term=TABLE B.term
and
TABLE A.crse_nbr=TABLE B.crse_nbr
and
TABLE B.term=TABLE C.term
and
TABLE B.crse_nbr=TABLE C.crse_nbr
and
TABLE A.session=TABLE C.session
and
TABLE C.location in ('PC','BT')
The query so far just retrieves:
ID term title location
1 0094 test PC
2 0094 test PC
2 0094 test3 BT
3 0094 test4 BT
========================
Some of these IDs are also at different location(s) so I really I need:
ID term title location
1 0094 test PC
1 0094 test1 ON
1 0094 test2 DC
2 0094 test PC
2 0094 test3 BT
3 0094 test4 BT
3 0094 test5 SD
ID 4 shouldn't be retrieved since they only have location HN and not at a PC and/or BT location.
I really appreciate all help.
TABLE A
ID term crse_nbr
1 0094 1
1 0094 5
1 0094 6
2 0094 1
2 0094 7
3 0094 8
3 0094 9
4 0096 10
TABLE B
term crse_nbr session title
0094 1 1 test
0094 5 1 test1
0094 6 1 test2
0094 7 1 test3
0094 8 1 test4
0094 9 1 test5
0096 10 2 test6
term crse_nbr session location
0094 1 1 PC
0094 5 1 ON
0094 6 1 DC
0094 7 1 BT
0094 8 1 BT
0094 9 1 SD
0096 10 2 HN
What I have so far:
select TABLE A.ID, TABLE B.term, TABLE B.title, TABLE C.location from
TABLE A,
TABLE B,
TABLE C,
where
TABLE A.term=TABLE B.term
and
TABLE A.crse_nbr=TABLE B.crse_nbr
and
TABLE B.term=TABLE C.term
and
TABLE B.crse_nbr=TABLE C.crse_nbr
and
TABLE A.session=TABLE C.session
and
TABLE C.location in ('PC','BT')
The query so far just retrieves:
ID term title location
1 0094 test PC
2 0094 test PC
2 0094 test3 BT
3 0094 test4 BT
========================
Some of these IDs are also at different location(s) so I really I need:
ID term title location
1 0094 test PC
1 0094 test1 ON
1 0094 test2 DC
2 0094 test PC
2 0094 test3 BT
3 0094 test4 BT
3 0094 test5 SD
ID 4 shouldn't be retrieved since they only have location HN and not at a PC and/or BT location.
I really appreciate all help.