473,473 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Plesae help with this query

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
2 1943
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Juho Saarikko | last post by:
I made a Python script which takes Usenet message bodies from a database, decodes uuencoded contents and inserts them as Large Object into a PostGreSQL database. However, it appears that the to...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
3
by: Brian Oster | last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a query that used to execute in under 2 seconds, now takes over 8 Minutes to complete. Any ideas on what the heck might be going...
1
by: Mike Chamberlain | last post by:
Hi all. I'm trying to extend the Microsoft Enterprise Library Data Access Application Block (http://msdn.microsoft.com/library/en-us/dnpag2/html/daab.asp?frame=true) to work with a Borland...
0
by: Jedi Knight | last post by:
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...
3
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
2
by: chromis | last post by:
Hi there, I've been reading an OOP book recently and it gives some nice Adaptor / Template patttern code to wrap around the php Mysql functions. I thought that I'd try and create a Simple Address...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.