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

Criteria for a query

158 100+
I know that I should be able to wrap my head around this but for some reason my brain isn’t there today.
This is my query to which I need help in setting the fields criteria:
Expand|Select|Wrap|Line Numbers
  1. SELECT LocSymbioseT.LocCondID, LocSymbioseT.LocID, LocSymbioseT.TenantID, LocSymbioseT.BuildingID, LocLivCondT.LWallTrimIN, LocLivCondT.LCeilingIN, LocLivCondT.LfloorIN, LocLivCondT.LTvTelephoneSwitchOutletIN, LocLivCondT.LClosetIN, LocLivCondT.LIlluminationIN, LocLivCondT.LWindowCoveringIN, LocLivCondT.LThermostatIN
  2. FROM LocSymbioseT LEFT JOIN LocLivCondT ON LocSymbioseT.LocCondID = LocLivCondT.LocCondID;
  3.  
LocCondID = Parent/Child
LocID=The suite
TenantID= The Tenant who occupies the suite
BuildingID= The building in which the suite is located
*IN=The fields I need to set criteria for
Every field can have one of eleven possible ID Reference number of a letter code. The code that I am after is “R” or “10”(as I use its ID instead which stands for “repair”)
So each *IN field can potentially have a “R” code value but unlikely as everything in the suite would trashed and everything would require repair. So some will have a “R” some won’t. What I need is a criteria that will extract the “R” from any and all of them.
The *IN fields are all multi-select because there is the possibility to have a combination of letter codes for each field.
If I put a “10” in the criteria box and if there is a record that has an R in the field it will show up. The problem is I can’t put “10” in every field because I don’t return anything when I run the query.
From what I’ve learned so far I think a IIF statement would be require but don’t really know how to formulate it. The statement also must account for Null value as well. Can anyone help?
Feb 12 '10 #1

✓ answered by orangeCat

My question really is why a Left Join as compared to EQuiJoin?
For example:



SELECT
LocSymbioseT.LocCondID
, LocSymbioseT.LocID
, LocSymbioseT.TenantID
, LocSymbioseT.BuildingID
, LocLivCondT.LWallTrimIN
, LocLivCondT.LCeilingIN
, LocLivCondT.LfloorIN
, LocLivCondT.LTvTelephoneSwitchOutletIN
, LocLivCondT.LClosetIN
, LocLivCondT.LIlluminationIN
, LocLivCondT.LWindowCoveringIN
, LocLivCondT.LThermostatIN
FROM LocSymbioseT , LocLivCondT
WHERE
LocSymbioseT.LocCondID = LocLivCondT.LocCondID AND
(LocLivCondT.LWallTrimIN = "R" or
LocLivCondT.LCeilingIN = "R" or
LocLivCondT.LfloorIN = "R" or
LocLivCondT.LTvTelephoneSwitchOutletIN = "R" or
LocLivCondT.LClosetIN = "R" or
LocLivCondT.LIlluminationIN = "R" or
LocLivCondT.LWindowCoveringIN = "R" or
LocLivCondT.LThermostatIN = "R");

Does this query give you what you need?

10 1345
orangeCat
83 64KB
What is the question or query you're trying to answer?
In plain english, what are you hoping to find/select?
Feb 12 '10 #2
jaad
158 100+
The database is about maintaining suites in an apartment building. This example that I gave is only one table. I have several for different area in the suite. Example: Living room table, kitchen, table , bathroom table and so on. when I perform a condition report each item in the suite is given a grade: Good, Fair, Poor, Stained, Broken, Repair ect.

what I want to have is when I finished entering the data for a condition report, all item that requires "repair" or "R" to be pulled out so I can create a work order about the item.
Feb 12 '10 #3
orangeCat
83 64KB
Ok, another question. Why do you use Left Join?
Any o fthe fields *IN could have a "R" epair which you want to select -- right?
Feb 12 '10 #4
jaad
158 100+
Because I need fields in LocSymbioseT for later use. maybe I can add it after the fact if it will help?
Feb 12 '10 #5
orangeCat
83 64KB
My question really is why a Left Join as compared to EQuiJoin?
For example:



SELECT
LocSymbioseT.LocCondID
, LocSymbioseT.LocID
, LocSymbioseT.TenantID
, LocSymbioseT.BuildingID
, LocLivCondT.LWallTrimIN
, LocLivCondT.LCeilingIN
, LocLivCondT.LfloorIN
, LocLivCondT.LTvTelephoneSwitchOutletIN
, LocLivCondT.LClosetIN
, LocLivCondT.LIlluminationIN
, LocLivCondT.LWindowCoveringIN
, LocLivCondT.LThermostatIN
FROM LocSymbioseT , LocLivCondT
WHERE
LocSymbioseT.LocCondID = LocLivCondT.LocCondID AND
(LocLivCondT.LWallTrimIN = "R" or
LocLivCondT.LCeilingIN = "R" or
LocLivCondT.LfloorIN = "R" or
LocLivCondT.LTvTelephoneSwitchOutletIN = "R" or
LocLivCondT.LClosetIN = "R" or
LocLivCondT.LIlluminationIN = "R" or
LocLivCondT.LWindowCoveringIN = "R" or
LocLivCondT.LThermostatIN = "R");

Does this query give you what you need?
Feb 12 '10 #6
jaad
158 100+
I've tried something similar to that but I can't because of the multivalues fields *IN.
Feb 12 '10 #7
orangeCat
83 64KB
I don't understand. Can you show a couple of data records?

Are you not looking for records where any or any number of these fields whose name ends in "IN" contain an "R"?
Feb 12 '10 #8
jaad
158 100+
Here is another representation. "One that doesn't work unless all field have a value "10" (10 is the ID for "R" in those multivalues fields)

Expand|Select|Wrap|Line Numbers
  1. SELECT LocSymbioseT.LocCondID, LocSymbioseT.LocID, LocSymbioseT.TenantID, LocSymbioseT.BuildingID, LocLivCondT.LWallTrimIN, LocLivCondT.LCeilingIN, LocLivCondT.LfloorIN, LocLivCondT.LTvTelephoneSwitchOutletIN, LocLivCondT.LClosetIN, LocLivCondT.LIlluminationIN, LocLivCondT.LWindowCoveringIN, LocLivCondT.LThermostatIN
  2. FROM LocSymbioseT INNER JOIN LocLivCondT ON LocSymbioseT.LocCondID = LocLivCondT.LocCondID
  3. WHERE (((LocLivCondT.LWallTrimIN.Value)=10) AND ((LocLivCondT.LCeilingIN.Value)=10) AND ((LocLivCondT.LfloorIN.Value)=10) AND ((LocLivCondT.LTvTelephoneSwitchOutletIN.Value)=10) AND ((LocLivCondT.LClosetIN.Value)=10) AND ((LocLivCondT.LIlluminationIN.Value)=10) AND ((LocLivCondT.LWindowCoveringIN.Value)=10) AND ((LocLivCondT.LThermostatIN.Value)=10));
Which would probably never happen. In a real situation, one or two , even maybe three field would have a "10" in it. so no mater if the other field have it or not I still want the ones that do have a value of 10 to come out on the query.
Feb 12 '10 #9
jaad
158 100+
yIPEE ok I got it. I did what you suggested. but I did it the right way. I was entering them all and using AND instead of OR. I knew my brain wasn't working right today. thanks a bunch Orange Cat
Feb 12 '10 #10
orangeCat
83 64KB
Glad to help, good luck with your project.
Feb 12 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: AAVF | last post by:
Hi We have a problem with a query. An Access database links via ODBC to a UNIX server. To speed things, we use the ODBC to load the relevant tables to the local PC that runs Access so that...
2
by: Matthew | last post by:
Hey , I have built a query which takes values from unbounded fields on a form, and it all works except for one thing. I have a few fields in my query that are dates. I also have a start and...
1
by: S. van Beek | last post by:
Dear reader, How can I filter a numeric field with Like as criteria in a query. To filter a numeric field with <10 as criteria this will com back with the result of those records for which...
0
by: Greg Strong | last post by:
Hello All, In the past I've used a combo box with the 'row source' being an Access SQL union query to select "All" or 1 for only 1 criteria in a query. An example is as follows: SELECT 0 As...
0
by: MLH | last post by:
I have an A97 query (qryVehiclesNowners2) that has a table field in it named . Depending on the selections made in a number of criteria choices on a form, a field on the form will have string...
3
by: MLH | last post by:
Am repeating question with different subject heading, perhaps stating more clearly my problem... I have an A97 query (qryVehiclesNowners2) that has a table field in it named . Depending on the...
4
by: meganrobertson22 | last post by:
Hi Everyone- I have a question about how to add and then use the "All" selection in a combo box. I am trying to figure out how to: (1) add "All" as a selection to a combo box and then (2)...
2
by: Mark Roughton | last post by:
I have a form where the users need to view records for various criteria, one of which is a date field on which they may wish to view all related data for the selected date, for all dates upto and...
13
by: Robertf987 | last post by:
Hi, Yet another thing I need help with I'm affraid. I'll first explain what I want, then I'll try to explain what I have. I'm using Microsoft Access 2000. What I want is to be able to do a...
17
by: sharsy | last post by:
Hello guys, I would like some help in generating query criteria that will identify credit cards that have expired on an access database. The specific Field is formatted with a Data Type of...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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,...

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.