Solved

Access 2007 Queries

Posted on 2013-06-07
5
398 Views
Last Modified: 2013-06-07
I have a table that lists 100 employees information. One of the fields is a number code, which has many diff codes for some employees. The specific code I want is "001".

I know how to make the query work for just that code, it returns 50 employees.

Here is what I want. A query that will return all employees with the 001 code and the employees that dont have the 001 code.
0
Comment
Question by:CMILLER
5 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
<employees that dont have the 001 code. >

here is the query for employees that dont have the 001 code

select *
from TableName
where [code field] <> "001"
0
 

Author Comment

by:CMILLER
Comment Utility
I need one query that returns employees with the 001 code, which currently is 50 employees. I need the same query to return the other 50 employees that dont have the 001 code.

I have ten codes ( 001-010 ). All employees have atleast one of the ten codes.

My resulting query needs to return all 100 employees but I only need to know about the 001 code.
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
Comment Utility
>>My resulting query needs to return all 100 employees

Then why not simply use:

SELECT * FROM [TableName]

:)

Or is this what you mean:

SELECT *, IIf([the_code] = "001", "Has 001", "Not 001") AS [Whatever]
FROM [TableName]
0
 
LVL 19

Expert Comment

by:Eric Sherman
Comment Utility
<<<<<Here is what I want. A query that will return all employees with the 001 code and the employees that dont have the 001 code.>>>>

Wouldn't that be the same as selecting all employees from your table .... sorted by your code field????


ET
0
 

Author Closing Comment

by:CMILLER
Comment Utility
Matthew,

Thanks, this is what I needed, just didnt know how to explain it.

SELECT *, IIf([the_code] = "001", "Has 001", "Not 001") AS [Whatever]
FROM [TableName]
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now