473,385 Members | 1,821 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,385 software developers and data experts.

Conditional "Is Null" Query Criteria

Question deals with linking tables in queries. I'm not a code writer
so use the GUI for all my queries.

Table 1 - Master
Table 2 - Sub1
Table 3 - Sub 2

All 3 tables have the same key field.

I'm trying to find all the records that are in "Master", that are not
in Sub1 or Sub2. Just doing that I have but doing show me all in
"Master" and using Join Property 2 and Is Null for both Sub1 and Sub2.

What I really want to do though is show me all records in "Master"
that are not in Sub1 or Sub2, but only when Sub1.Fieldname = "Jones".
If I put "Jones" in the criteria section of query, I get nothing. I
know I could create another query for Sub1.Fieldname = "Jones" and do
the above off of that, but I'd rather not create the add'l queries.

I haven't understood how you can do the "Is not in table X, when only
looking at Table X records where Fieldname = "Jones".

Hope the above makes sense?
Jun 27 '08 #1
1 2571
YOu can try the following if Master, Sub1, Sub2 contain the exact same
fields (where this example is using the * wildcard)

select tA.* From Master tA Left Join
(
SELECT t1.*
FROM Mater t1 INNER JOIN Sub1 t2 ON t1.keyfld = t2.keyfld
union all
SELECT t1.*
FROM Master t1 INNER JOIN Sub2 t2 ON t1.keyfld = t2.keyfld
) tB on tA.keyfld = tB.fld
where tb.keyfld is null

If the tables are not exactly the same then you have to list the fields
you want to display. The catch if the tables are not all the same is
that for the Union All part you have to list the same number of fields
for each select statement. Just change keyfld to the name of your
actual keyfield. The t1, t2, tA, tB are just alias's for each of the
tables. t1 refers to Master in the Subquery, t2 = Sub1 in the first
select inside the subquery, and t2 = Sub2 in the 2nd select in the
subquery, then tA again refers to Master in the outer query, and tB
refers to the Subquery (thus the alias).

This will return all the records in Master which are not contained in
either of Sub1 or Sub2.
So if the tables are basically all the same - just different data then
just copy and paste the sql above in the Sql window of the Query Builder
and replace the table names wiht the

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #2

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

Similar topics

32
by: Nuno Paquete | last post by:
Hi group. I'm using this code to see if is there any parameter for variable "menu": if($_GET == "downloads") .... But this code log errors if there is no parameter passed (this heappens at...
7
by: Pablo J Royo | last post by:
Hello: i have a function that reads a file as an argument and returns a reference to an object that contains some information obtained from the file: FData &ReadFile(string FilePath); But ,...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
13
by: gary | last post by:
Hi, We all know the below codes are dangerous: { int *p = new int; delete p; delete p; } And we also know the compilers do not delete p if p==NULL. So why compilers do not "p = NULL"...
15
by: Bobby C. Jones | last post by:
Is there an advantage to either of these methods, or is it simply a matter of style? I used to use the "as" method, but later gave it up for the "is" method as the intent of the code seems a...
14
by: MuZZy | last post by:
Hi, Lately i've been (and still am) fixing some memory leaks problems in the project i just took over when i got this new job. Among the other issues i've noticed that for localy created objects...
7
by: Kenneth Brody | last post by:
(From something brought up on "Help with array/pointer segmentation fault needed" thread.) Is "?" a sequence point? Or, more directly, is the following defined? /* Will "ptr" be guaranteed...
3
by: kartoshka | last post by:
I'm writing a job application; English is not my native language & I'm having trouble translating some of the criteria requirements into what I know / have done (I have 5 years c / C++ experience...
7
mkremkow
by: mkremkow | last post by:
Hello all, Access 2003 Windows PC: I am trying to figure out why my Query isn't working. In this query, I want to get only those jobs that are still open and where at least one of four Yes/No...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.