473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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 1941
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.