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

Query to show data if other data doesn't exist

Access 2000 on windows XP

Below are examples of 2 tables I am trying to run the following query on. In the query, I only want one line item for each PartNumber. If the PartNumber has a PropertyName of "Value" I want it to list the PropertyValue. If it doesn't have a PropertName of "Value", I still want it to list the PartNumber. This seems like it should be fairly simple, but I am new to Access. Thanks for any help.

Rob


Table: PartNumbers
PartNumberID PartitionID PartNumber PartName PartLabel RefDesPre Description
1 0 CAP0402-OMIT ??? OMIT C CAP 0402 OMIT
2 0 CAP0402-SAT0 ??? SAT0 C CAP 0402 SAT

Table: PartProperties
PropID PartNumberID NameIndex PropertyType PropertyName PropertyValue
1 1 CAP0402-OMIT 1 Type Capacitor
2 2 CAP0402-SAT0 1 Type Capacitor
3 2 CAP0402-SAT0 1 Value 0

Current Query
PartNumberID PartitionID PartNumber PartName PartLabel RefDesPre Description PropertyValue
1 0 CAP0402-OMIT ??? OMIT C CAP 0402 OMIT Capacitor
2 0 CAP0402-SAT0 ??? SAT0 C CAP 0402 SAT Capacitor
2 0 CAP0402-SAT0 ??? SAT0 C CAP 0402 SAT 0

Expand|Select|Wrap|Line Numbers
  1. SELECT PartNumbers.*, PartProperties.PropertyValue
  2. FROM PartNumbers, PartProperties
  3. WHERE (((PartNumbers.PartitionID)=0) AND ((PartNumbers.PartNumberID)=([PartProperties].[PartNumberID])) AND ((PartProperties.PropertyName)="Value" Or (PartProperties.PropertyName)="Type"));
Ideal Results
1 0 CAP0402-OMIT ??? OMIT C CAP 0402 OMIT Capacitor
2 0 CAP0402-SAT0 ??? SAT0 C CAP 0402 SAT 0
Apr 7 '07 #1
2 1927
nico5038
3,080 Expert 2GB
First create a query qryPartProperties that's selecting the PartNumberID and the PropertyName and filtering for "Value" of the latter.

Then you'll need to create an outer join query between the PartNumbers table and qryPartProperties.
Just placeboth of them into the graphical query editor and drag and drop the PartNumberID from one table to the other.
Now double-click the connection line and chose option 2 or 3 making the PartNumbers table "leading".
Finally place the PartNumberID and other fields from the PartNumbers table and add the needed fields from qryPartProperties..
Because of the OUTER JOIN only the "Value" rows will hold data, the other fields from the qryPartProperties will be empty.

Nic;o)
Apr 8 '07 #2
Exactly what I needed!
Thanks
Apr 8 '07 #3

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

Similar topics

13
by: aaron | last post by:
I have a question about (i think) joining. If I have a table in a database that has this info: key - name - favorite 1 - john - 2 2 - judy - 3 3 - joe - 1 the favorite icecream...
2
by: Pete | last post by:
Before I get started with the question, does anyone have a (single) good book recommendation for database design? Not an Access-specific book, but something geared toward helping me figure out...
4
by: Alan Lane | last post by:
Hello world: I'm including both code and examples of query output. I appologize if that makes this message longer than it should be. Anyway, I need to change the query below into a pivot table...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
3
by: Mike Charney | last post by:
I have a two part question: First I want to insert data into a table and I am using the following command: INSERT INTO tblmain SELECT field1, field2, etc... FROM tblimport WHERE ?????? The...
6
by: John | last post by:
Hi I have the following query; SELECT Clients.ID, Clients.Company, Clients. FROM Clients WHERE Clients. Not In (SELECT FROM ) When I do not use the keyword Not it works but not with...
2
by: mndprasad | last post by:
Hi friends, Am new to AJAX coding, In my program am going to have two texbox which going to implent AJAX from same table. One box is going to retrieve the value of other and vice...
9
by: Sinner | last post by:
Hi, I have a field name 'USER' in tableMAIN. How do I replace the user names with corresponding user names. I can do that in xl using vlookup but now I'm trying to find a way to do that in...
3
by: thalamus | last post by:
Hello: I'm working with an URL with this query string at the end: /page/?item=01x-001/ I want to check to make sure the parameter "item" exists in the address, and that it is displayed...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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
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.