473,569 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stuck - Cant figure out a Query for this situation

I have run into a problem, I have 2 fields in my database, both key
fields:

Table 1
=====
Field X <key>
Field Y <key>

In field X, there are say about 3 records for each unique Field Y. I
let my users query the data base like follows:

Enter the Codes you want: 1000 and 3000 and 8500

So I want to pick up records where there will be the above values for
All Y values. i.e 1000/AAA, 3000/AAA, and 8500 for AAA - if there is
even ONE of the X values not matching a record without a matching X
value, leave it out.

i.e:
X=1000,Y=AAA
X=3000,Y=AAA
X=8500,Y=AAA
X=1000,Y=BBB
X=3000,Y=BBB
X=8500,Y=BBB
X=1000,Y=CCC
X=3000,Y=CCC
X=9999,Y=CCC

When the query runs, I want to see the following records:

X=1000,Y=AAA
X=3000,Y=AAA
X=8500,Y=AAA
X=1000,Y=BBB
X=3000,Y=BBB
X=8500,Y=BBB

BUT NOT:

X=1000,Y=CCC
X=3000,Y=CCC
X=9999,Y=CCC

because one of the X values was not matched (the last X value =9999 and
not one of the requirements of the search)

So I guess I want something like this:

SELECT X,Y from TABLE1 WHERE ALL Y VALUES HAVE ALL OF THESE X VALUES
(X=1000,X=3000, X=8500) IF ANY X VALUES ARE MISSING SKIP RECORD

^^ Hope the above makes sense... but I am really stuck. The only other
way I think I could do it is, copy all records that match all 3 X
values into a temp table, and weed out any that are missing any one of
the X values after they are copied but, I am running this on MYSQL 5.0
Clustered, and there is not enough room in memory for it probably...
and query time has to remain under a second.

Anyhelp would be appreciated...

Jan 3 '06 #1
2 1412
Nevermind, I figured it out... its a "Relational Division"

that was a kick in the groin, but I learned something here I think...

Jan 3 '06 #2
Hi Mike

You may want to check out http://www.aspfaq.com/etiquette.asp?id=5006 on how
to post useful DDL and example data. With information in a usable format you
are more likely to get a quicker and accurate answer.

John

"Mike Curry" <mm*****@rogers .com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Nevermind, I figured it out... its a "Relational Division"

that was a kick in the groin, but I learned something here I think...

Jan 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1204
by: chris | last post by:
a short while ago i was playing arround with the <DIV tag and wanted some text to dissapear - while i was doing this i had a situation where i could hide the info i wantd to hide but it would move the rest of the page up to take up the space. for example line 1 line 2 line 3
5
4953
by: Dimitri Furman | last post by:
Using SQL Server 2000 SP4. There is a relatively complex stored procedure that usually completes in less than 20 seconds. Occasionally it times out after 180 seconds. The SP is called via ADO 2.8, using adCmdStoredProc command type. If I use Profiler to capture the EXEC that ADO sends to run the procedure, and run that from QA, the...
17
2012
by: so many sites so little time | last post by:
all right so the script is pretty simple it goes it retrives what the id of the post is and it lets you edit it well no it doesnt. now if you go to www.kirewire.com/pp2/index/php you will see a number 1 that is the value of collumn home_id which is set to auto increment ect ect but this script which gets the id of home_id of a row and...
10
1861
by: Cliff | last post by:
Greetings, I have been trying to teach myself C++ over the past few weeks and have finally came across a problem I could not fix. I made a simple program that prints out a square or rectangle using the * character. The program was just for practice but I am having problems. My main problem is, in my program I use 4 functions to change or...
6
1693
by: StephQ | last post by:
I need to implement an algorithm that takes as input a container and write some output in another container. The containers involved are usually vectors, but I would like not to rule out the possibility of using lists. The problem is that I need two versions of it, depending if I'm adding the generated (by the algorithm) values to the target...
1
2717
by: Rahul Babbar | last post by:
Hi, I am having a difficult situation in here... Seems there is a query to create an index on a table and has just got stuck..... It is showing that it is in UOW executing status (in DB2 monitor) for the last 1 day. When i try to force the application, it gives the message that it has been killed, but it not removed.
17
1345
by: Bill Cunningham | last post by:
I have this code and it will not compile telling me that pow is undefined. I'm not quite sure what to make of this so I thought I'd get some feedback. #include <stdio.h> #include <stdlib.h> #include <math.h> int main (int argc, char *argv)
2
2518
by: Mucahit ikiz | last post by:
I cant make a full dynamic query in LINQ I have 2 situation methods (only_exp_query, only_tbl_query) those are working. .... using System.Linq.Dynamic; using System.Data.Linq; .... string connString = @"Data Source=.;Initial
4
3835
by: MeDontGetSomething | last post by:
Hi What is the easiest way to format c drive from usb drive without using XP instalation disk. That was the shor story, this the long one if someone cares to read:) See, the situation is: 1) i had xp home edition on my laptop, and i wanted to upgrade to xp pro
0
7695
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7668
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6281
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5509
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5218
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.