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

Plesae help with this query

P: n/a
Hi,

I think I need to use an EXISTS query, but I am not vey proficient with
it and don't quite have a handle on the logic of this query yet.

query1, winners, has 3 fields that I'm concerend with
table2, players, has 1 field that I'm concerned with
they are linked with an ID.
I've already managed to get one part of my question answered. I had
the players table and the time table, and a simple query that combines
them so i can see the finishing times of each player.

Now what I need to do is get a query that displays the finishing times
only for the players that exist in each of the 3 fields of the winners
table.

example:
query1 (all players and their times - the * is to make it clearer later
in this msg)
playerid, time
1,5 *
2,7
3,4 *
4,9
5,3 *
6,8

winners table (each record is a new race - i want 1 race at a time)
first,second,third1
5,3,1

Because of the nature of my database (it's a bit more complex than I've
laid out here), I had to separate the winners from the times.

what I want to return is this query:
first time ,second time,third time
3, 4, 5

basically, the times of the 3 winners.

I'm having problems because it's not a simple 1-1, the times table is
laid out nicely, but the winners table is field based, not record
based.

any help would be appreciated and if possible explain it so I can learn
how to fish.

thx,
Bodi

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Try something like:

SELECT query1.* FROM query1
WHERE EXISTS
(SELECT winners.* FROM winners WHERE winners.first=query1.playerid OR
winners.second=query1.playerid OR winners.third=query1.playerid;);

"Jedi Knight" <az*****@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi,

I think I need to use an EXISTS query, but I am not vey proficient with
it and don't quite have a handle on the logic of this query yet.

query1, winners, has 3 fields that I'm concerend with
table2, players, has 1 field that I'm concerned with
they are linked with an ID.
I've already managed to get one part of my question answered. I had
the players table and the time table, and a simple query that combines
them so i can see the finishing times of each player.

Now what I need to do is get a query that displays the finishing times
only for the players that exist in each of the 3 fields of the winners
table.

example:
query1 (all players and their times - the * is to make it clearer later
in this msg)
playerid, time
1,5 *
2,7
3,4 *
4,9
5,3 *
6,8

winners table (each record is a new race - i want 1 race at a time)
first,second,third1
5,3,1

Because of the nature of my database (it's a bit more complex than I've
laid out here), I had to separate the winners from the times.

what I want to return is this query:
first time ,second time,third time
3, 4, 5

basically, the times of the 3 winners.

I'm having problems because it's not a simple 1-1, the times table is
laid out nicely, but the winners table is field based, not record
based.

any help would be appreciated and if possible explain it so I can learn
how to fish.

thx,
Bodi

Nov 13 '05 #2

P: n/a
Try something like:

SELECT query1.* FROM query1
WHERE EXISTS
(SELECT winners.* FROM winners WHERE winners.first=query1.playerid OR
winners.second=query1.playerid OR winners.third=query1.playerid;);

"Jedi Knight" <az*****@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi,

I think I need to use an EXISTS query, but I am not vey proficient with
it and don't quite have a handle on the logic of this query yet.

query1, winners, has 3 fields that I'm concerend with
table2, players, has 1 field that I'm concerned with
they are linked with an ID.
I've already managed to get one part of my question answered. I had
the players table and the time table, and a simple query that combines
them so i can see the finishing times of each player.

Now what I need to do is get a query that displays the finishing times
only for the players that exist in each of the 3 fields of the winners
table.

example:
query1 (all players and their times - the * is to make it clearer later
in this msg)
playerid, time
1,5 *
2,7
3,4 *
4,9
5,3 *
6,8

winners table (each record is a new race - i want 1 race at a time)
first,second,third1
5,3,1

Because of the nature of my database (it's a bit more complex than I've
laid out here), I had to separate the winners from the times.

what I want to return is this query:
first time ,second time,third time
3, 4, 5

basically, the times of the 3 winners.

I'm having problems because it's not a simple 1-1, the times table is
laid out nicely, but the winners table is field based, not record
based.

any help would be appreciated and if possible explain it so I can learn
how to fish.

thx,
Bodi

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.