473,396 Members | 2,024 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,396 software developers and data experts.

criteria matching with table is null

I am not sure if I am asking the right question in the subject here.
But, here is my problem. I have 5tables/queries with various data
like below.

Table1: CustomerID1, Field1, Field2
Table2: CustomerID1, Field5, Field6
Table3: CustomerID2, Field7, Field8 (customerID1 does not exist in
the table)
....

So, how do I create query to "skip" over table3 and show me if
criterias are met in table1 & table2, then show me the customer?
When I do a IsNull([CustomerID] with the table, it does not skip over,
it displays other customerIDs.
Here are the actual SQL:
SELECT Trim([ELastName] & ", " & [EFirstName]) AS FullName,
TNameInfo.ELastName, TNameInfo.EFirstName, TNameInfo.CName,
TFellowship.Initial, TFellowship.FChinese, Ability.NameID,
Ability.QID, Ability.TQuestion.Description, Ability.CodeID,
Ability.TCode.Description, Experience.QID,
Experience.TQuestion.Description, Experience.CodeID,
Experience.TCode.Description, Heart.QID, Heart.TQuestion.Description,
Heart.CodeID, Heart.TCode.Description, Personality.QID,
Personality.TQuestion.Description, Personality.CodeID,
Personality.TCode.Description, SpiritualGift.QID,
SpiritualGift.TQuestion.Description, SpiritualGift.CodeID,
SpiritualGift.TCode.Description
FROM TFellowship INNER JOIN (((((SpiritualGift INNER JOIN Personality
ON SpiritualGift.NameID = Personality.NameID) INNER JOIN Heart ON
Personality.NameID = Heart.NameID) INNER JOIN Experience ON
Heart.NameID = Experience.NameID) INNER JOIN Ability ON
Experience.NameID = Ability.NameID) INNER JOIN TNameInfo ON
SpiritualGift.NameID = TNameInfo.NameID) ON TFellowship.FellowshipID =
TNameInfo.FellowshipID
WHERE (((Ability.QID) Like IIf(IsNull([Forms]![0F_All]![AB1])=True,"*",
[Forms]![0F_All]![AB1])) AND ((Ability.CodeID) Like IIf(IsNull([Forms]!
[0F_All]![AB2])=True,"*",[Forms]![0F_All]![AB2])) AND
((Experience.QID) Like IIf(IsNull([Forms]![0F_All]![Ex1])=True,"*",
[Forms]![0F_All]![Ex1])) AND ((Experience.CodeID) Like
IIf(IsNull([Forms]![0F_All]![Ex2])=True,"*",[Forms]![0F_All]![Ex2]))
AND ((Heart.QID) Like IIf(IsNull([Forms]![0F_All]![Pa1])=True,"*",
[Forms]![0F_All]![Pa1])) AND ((Heart.CodeID) Like IIf(IsNull([Forms]!
[0F_All]![Pa2])=True,"*",[Forms]![0F_All]![Pa2])) AND
((Personality.QID) Like IIf(IsNull([Forms]![0F_All]![Pe2])=True,"*",
[Forms]![0F_All]![Pe2])) AND ((Personality.CodeID) Like
IIf(IsNull([Forms]![0F_All]![Pe1])=True,"*",[Forms]![0F_All]![Pe1]))
AND ((SpiritualGift.QID) Like IIf(IsNull([Forms]![0F_All]!
[SG1])=True,"*",[Forms]![0F_All]![SG1])) AND ((SpiritualGift.CodeID)
Like IIf(IsNull([Forms]![0F_All]![SG2])=True,"*",[Forms]![0F_All]!
[SG2])));

Any hint will be appreciated.

Perry
Jan 11 '08 #1
5 1792
On Jan 11, 3:18*pm, perry...@yahoo.com wrote:
I am not sure if I am asking the right question in the subject here.
But, here is my problem. *I have 5tables/queries with various data
like below.

Table1: CustomerID1, Field1, Field2
Table2: CustomerID1, Field5, Field6
Table3: CustomerID2, Field7, Field8 *(customerID1 does not exist in
the table)
...

So, how do I create query to "skip" over table3 and show me if
criterias are met in table1 & table2, then show me the customer?
When I do a IsNull([CustomerID] with the table, it does not skip over,
it displays other customerIDs.

Here are the actual SQL:
SELECT Trim([ELastName] & ", " & [EFirstName]) AS FullName,
TNameInfo.ELastName, TNameInfo.EFirstName, TNameInfo.CName,
TFellowship.Initial, TFellowship.FChinese, Ability.NameID,
Ability.QID, Ability.TQuestion.Description, Ability.CodeID,
Ability.TCode.Description, Experience.QID,
Experience.TQuestion.Description, Experience.CodeID,
Experience.TCode.Description, Heart.QID, Heart.TQuestion.Description,
Heart.CodeID, Heart.TCode.Description, Personality.QID,
Personality.TQuestion.Description, Personality.CodeID,
Personality.TCode.Description, SpiritualGift.QID,
SpiritualGift.TQuestion.Description, SpiritualGift.CodeID,
SpiritualGift.TCode.Description
FROM TFellowship INNER JOIN (((((SpiritualGift INNER JOIN Personality
ON SpiritualGift.NameID = Personality.NameID) INNER JOIN Heart ON
Personality.NameID = Heart.NameID) INNER JOIN Experience ON
Heart.NameID = Experience.NameID) INNER JOIN Ability ON
Experience.NameID = Ability.NameID) INNER JOIN TNameInfo ON
SpiritualGift.NameID = TNameInfo.NameID) ON TFellowship.FellowshipID =
TNameInfo.FellowshipID
WHERE (((Ability.QID) Like IIf(IsNull([Forms]![0F_All]![AB1])=True,"*",
[Forms]![0F_All]![AB1])) AND ((Ability.CodeID) Like IIf(IsNull([Forms]!
[0F_All]![AB2])=True,"*",[Forms]![0F_All]![AB2])) AND
((Experience.QID) Like IIf(IsNull([Forms]![0F_All]![Ex1])=True,"*",
[Forms]![0F_All]![Ex1])) AND ((Experience.CodeID) Like
IIf(IsNull([Forms]![0F_All]![Ex2])=True,"*",[Forms]![0F_All]![Ex2]))
AND ((Heart.QID) Like IIf(IsNull([Forms]![0F_All]![Pa1])=True,"*",
[Forms]![0F_All]![Pa1])) AND ((Heart.CodeID) Like IIf(IsNull([Forms]!
[0F_All]![Pa2])=True,"*",[Forms]![0F_All]![Pa2])) AND
((Personality.QID) Like IIf(IsNull([Forms]![0F_All]![Pe2])=True,"*",
[Forms]![0F_All]![Pe2])) AND ((Personality.CodeID) Like
IIf(IsNull([Forms]![0F_All]![Pe1])=True,"*",[Forms]![0F_All]![Pe1]))
AND ((SpiritualGift.QID) Like IIf(IsNull([Forms]![0F_All]!
[SG1])=True,"*",[Forms]![0F_All]![SG1])) AND ((SpiritualGift.CodeID)
Like IIf(IsNull([Forms]![0F_All]![SG2])=True,"*",[Forms]![0F_All]!
[SG2])));

Any hint will be appreciated.

Perry
Perry,
I am not sure that I fully understand your question, but try this.
Create a query for table3 that limits it the way you want to - taking
out or leaving in nulls. Then use that query instead of the table in
the above query.
HTH
P
Jan 12 '08 #2
P,
I am sorry for being so confusing. I just don't know how to
ask.,.. let me give it one more try: (In general, this is a problem
because the table was inproperly designed in the first place, that is
why I am trying to "program" around it.)

I am simplifying the situation here:

Table1: CustomerID, Field1
Table2: CustomerID, Field2
Table3: CustomerID, Field3

Then I have a blank form with 3 fields: FormField1, FormField2 &
FormField3

If Table1Field1=FormField1 and Table2Field2=FormField2 and
Table3Field3=FormField3, then display the Common Customer ID (Who is
it?)

Assuming the first 2 criteria are met for CustomerID = 11, but the
third criteria, in table 3, since CutomerID #11 does not even exist, I
would like for the query result to include CustomerID #11. (Because
the info was missing does not mean it may not match, we just fail to
create a customerID #11 for table3.) In other words, how do I not
exclude results CustomerID #11 from the result even if Table3 does not
contain customerID #11's data?

FYI: The above tables are actual queries (everything is built into
one big table, not so good design in the beginning by someone else).
I am just trying to savage this. Hope this help a little.

Perry
Jan 13 '08 #3
On Jan 12, 7:01*pm, perry...@yahoo.com wrote:
P,
* * *I am sorry for being so confusing. *I just don't know how to
ask.,.. let me give it one more try: *(In general, this is a problem
because the table was inproperly designed in the first place, that is
why I am trying to "program" around it.)

I am simplifying the situation here:

Table1: CustomerID, Field1
Table2: CustomerID, Field2
Table3: CustomerID, Field3

Then I have a blank form with 3 fields: FormField1, FormField2 &
FormField3

If Table1Field1=FormField1 and Table2Field2=FormField2 and
Table3Field3=FormField3, then display the Common Customer ID (Who is
it?)

Assuming the first 2 criteria are met for CustomerID = 11, but the
third criteria, in table 3, since CutomerID #11 does not even exist, I
would like for the query result to include CustomerID #11. *(Because
the info was missing does not mean it may not match, we just fail to
create a customerID #11 for table3.) * In other words, how do I not
exclude results CustomerID #11 from the result even if Table3 does not
contain customerID #11's data?

FYI: *The above tables are actual queries (everything is built into
one big table, not so good design in the beginning by someone else).
I am just trying to savage this. *Hope this help a little.

Perry
if CustomerID is unique in each table (no duplictes) then you just
neet to do an outer join (left or right).
SELECT * FROM (table1 INNER JOIN table2 ON
table1.customerid=table2.customerid) LEFT JOIN table3 on
table1.customerid=table3.customerid
WHERE table1.customerID=11
When you create your joins, in the query editor, double click on the
line that joins the two tables and you can choose an outer join.

if CustomerID is not unique and you are using other criteria to limit
your query, you will have to do some other stuff.
Jan 15 '08 #4
This does not work too well for me, because like I described, the main
problem is some table do not have that particular customerID at all.
But I do not want to exclude those customerID that does not exist in a
particular table. What I am seeing is when I just search 1 query, it
yields 6 records; but when I search thru this inner/outer join as you
suggested, it yields only 4 records (because 1 of the tables do not
contain that particular customerID). Thanks for your help, any other
thoughts?

Perry
Jan 16 '08 #5
On Jan 15, 6:11*pm, perry...@yahoo.com wrote:
This does not work too well for me, because like I described, the main
problem is some table do not have that particular customerID at all.
But I do not want to exclude those customerID that does not exist in a
particular table. *What I am seeing is when I just search 1 query, it
yields 6 records; but when I search thru this inner/outer join as you
suggested, it yields only 4 records (because 1 of the tables do not
contain that particular customerID). *Thanks for your help, any other
thoughts?

Perry
You need to create two separate queries and put one within the other.
Create a query on table1 and 2 that has the criteria in it (query1)
and then create another query (query2) that does a left join between
query1 and 2
You can also do this in a derived table if you are daring enough.

Query1:
SELECT * FROM (table1 INNER JOIN table2 ON
table1.customerid=table2.customerid)
WHERE table1.customerID=11

Query2:
Select * FROM query1 LEFT JOIN table3 on
query1.whatever=table3.whatever

HTH
Feb 1 '08 #6

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

Similar topics

1
by: M Wells | last post by:
Hi All, Sorry if the subject line is too obscure -- I couldn't think of a way of describing this request. I have a table that contains approximately 1 million records. I want to be able to...
8
by: Steve Jorgensen | last post by:
Mailing List management is a good example of a case where my conundrum arises. Say there is a m-m relationship between parties and groups - anyone can be a member of any combintation of groups. ...
2
by: MLH | last post by:
Why does this one produce 9 records... SELECT DISTINCT tblVehicleJobs.VehicleJobID, tblVehicleJobs.Reclaimed, tblVehicleJobs.VSaleID, tblVehicleJobs.ENF262Written FROM tblVehicleJobs WHERE...
3
by: Rebekkah | last post by:
I did a search but couldn't find a question similar to mine. I need to count the values in a textbox on a report and have the count subtotal in a group footer. But I need three different counts on...
16
by: The Frog | last post by:
Hi Everyone, I have a small problem that doesnt seem to make any sense. I am using Access 97, and have a query that selects data from a text field, converts it to type Lng. This seems to work...
1
klarae99
by: klarae99 | last post by:
I am new to this forum and new to Access 2003...this is my first database that is more than a table and some reports. The database I am working on is for inventory control. My current project is to...
8
by: limperger | last post by:
Hello everyone! First and foremost, my apologies for the title of the post. It is not very clarifying of what the problem is about, but I didn't know how to put it... My problem is as follows: I...
2
by: Denise | last post by:
Front end is Access 2002, back end is linked Oracle tables. My users need to describe things in feet and inches and want to use the standard ' and " abbrevations. On a testing form I go to a...
8
by: Dr Al | last post by:
I have a table with four date fields, some of which may not be filled in based on our data entry needs. I have a criteria set as <date()-180 which is supposed to pull dates older than 180 days ago....
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...
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...
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
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...
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,...

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.