473,466 Members | 4,850 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

"Except" in Select Statement

6 New Member
I need to select cells from one table that do not appear in a second table. I know that this can be done in some flavors of SQL by using Except:

Select Unit_PK From Table1
Except
Select Unit_PK From Table2

This would give me the Unit_PK cells in Table1 that do not exist in Table2.

Microsoft Access apparently does not allow Except or Minus in the SQL statement, so I am wondering if this is possible some other way. Your help is greatly appreciated.

Cheers -

george
Aug 26 '08 #1
4 12194
FishVal
2,653 Recognized Expert Specialist
Hello, George.

The same could be done with outer join.
Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.Unit_PK FROM Table1 LEFT JOIN Table2 ON Table1.Unit_PK=Table2.Unit_PK WHERE IsNull(Table2.Unit_PK);
  2.  
Aug 26 '08 #2
hjozinovic
167 New Member
This is what you should do:
[HTML]Create Query based on Table1 and Table2.
Join between two tables should be set so that ALL records from one table are included and ONLY those from other table where the join fields are the same.
In your case Table1 has them all so it should include all the records from Table1 and only those from Table2 where the join fields are the same.
In WHERE row for the join field from Table2 put : IsNull[/HTML]

The query selects all the records from Table1 and matching records from Table2 leaving blanks in the field from Table2 where the values are missing.
After selecting only those records that are null in field from Table2 you get 'the difference'

This is my test query:
Expand|Select|Wrap|Line Numbers
  1. SELECT MainProfile.EmployeeID, LeaveApply.LaEmployeeID
  2. FROM MainProfile LEFT JOIN LeaveApply ON MainProfile.EmployeeID = LeaveApply.LaEmployeeID
  3. WHERE (((LeaveApply.LaEmployeeID) Is Null));
Aug 26 '08 #3
GLSmyth
6 New Member
IsNull is the key I was missing. Thank you very much for the comments.

Cheers -

george
Aug 26 '08 #4
FishVal
2,653 Recognized Expert Specialist
You are quite welcome.

Best regards,
Fish
Aug 27 '08 #5

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

Similar topics

0
by: Raymond Arthur St. Marie II of III | last post by:
Del's "except"ional PEP Rejection Ladieees and Gentilmen and Pyth-O-neers of all ages. Step right up. Don't be shy. Come one come all. Be the first on your block TO GROK *THE* one *THE* only...
8
by: Adam Nemitoff | last post by:
Is is possible to construct a SELECT statement that contains a WHERE clause that uses the value from a column in the "next" row? ie. given a table with a single field named "myField" with the...
5
by: Rachel Weeden | last post by:
I'm working on an ASP Web application, and am having syntax issues in a WHERE statement I'm trying to write that uses the CInt Function on a field. Basically, I want to select records using...
1
by: arnold | last post by:
Hi, I've been knocking my head against the wall trying to create an XSL transform to perform "normalizations" of a set of XML files that have a common structure. % XML file before transform
3
by: Ernesto | last post by:
Within the scope of one Python file (say myFile.py), I'd like to print a message on ANY exception that occurs in THAT file, dependent on a condition. Here's the pseudocode: if...
5
by: Nebur | last post by:
I'm using the contract.py library, running Python 2.4.4. Now I'm confronted with the following exception backtrace: (...) File "/usr/lib/python2.4/site-packages/contract.py", line 1265, in...
0
by: egur | last post by:
Hi, I'm looking for reliable MySQL version (for Windows) that supports "EXCEPT" and "INTERSECT" execution. Would somebody recommend such version (and corresponding client), please?
9
by: Jameson.Quinn | last post by:
I have: try: for line in open(myFileName): count += 1 except IOError: print "Can't open myfile" (I know, this is bad, I never close the file, but its just for illustration). But then I...
56
by: Adem | last post by:
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" The C++ Standard (ISO/IEC 14882, Second edition, 2003-10-15) says under...
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
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,...
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,...
1
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.