A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

NOT IN (SQL) or Find Unmatched (+ other stuff)



 
 
Thread Tools Display Modes
  #1  
Old February 24th, 2010, 04:58 PM posted to microsoft.public.access.queries
Farkyss
external usenet poster
 
Posts: 25
Default NOT IN (SQL) or Find Unmatched (+ other stuff)

Big issue here trying to build a query that lists records whose serial number
DOES NOT appear in another table.
In SQL, would use the condition:
WHERE pd.SERIAL_NUMBER NOT IN (SELECT SERIAL_NUMBER FROM INSTALL)
Access 2007 ignores this caviat and displays all records
Have tried also building the query using the query wizard for finding
unmatched entries, displaying records from my table which do NOT appear in
the INSTALL table, matching on the SERIAL_NUMBER field.
Both methods fail. Any ideas?
I also have issue with the fact that many of standard SQL commands are just
simply not implemented in the SQL implementation in Access 2007 (such as
JOIN, JOIN USING) - is there a list of unsupported SQL commands anywhere?
  #2  
Old February 24th, 2010, 06:43 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default NOT IN (SQL) or Find Unmatched (+ other stuff)

Make sure you eliminate any NULLs in the sub-query.

WHERE pd.SERIAL_NUMBER NOT IN
(SELECT SERIAL_NUMBER
FROM INSTALL
WHERE Serial_Number is NOT NULL)

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Farkyss wrote:
Big issue here trying to build a query that lists records whose serial number
DOES NOT appear in another table.
In SQL, would use the condition:
WHERE pd.SERIAL_NUMBER NOT IN (SELECT SERIAL_NUMBER FROM INSTALL)
Access 2007 ignores this caviat and displays all records
Have tried also building the query using the query wizard for finding
unmatched entries, displaying records from my table which do NOT appear in
the INSTALL table, matching on the SERIAL_NUMBER field.
Both methods fail. Any ideas?
I also have issue with the fact that many of standard SQL commands are just
simply not implemented in the SQL implementation in Access 2007 (such as
JOIN, JOIN USING) - is there a list of unsupported SQL commands anywhere?

  #3  
Old February 24th, 2010, 07:20 PM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default NOT IN (SQL) or Find Unmatched (+ other stuff)

SELECT DISTINCT Install.SERIAL_NUMBER
FROM Install LEFT JOIN PD
ON Install.SERIAL_NUMBER = PD.SERIAL_NUMBER
WHERE PD.SERIAL_NUMBER Is Null
ORDER BY 1;

Select Install.SERIAL_NUMBER
FROM Install LEFT JOIN PD
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"Farkyss" wrote:

Big issue here trying to build a query that lists records whose serial number
DOES NOT appear in another table.
In SQL, would use the condition:
WHERE pd.SERIAL_NUMBER NOT IN (SELECT SERIAL_NUMBER FROM INSTALL)
Access 2007 ignores this caviat and displays all records
Have tried also building the query using the query wizard for finding
unmatched entries, displaying records from my table which do NOT appear in
the INSTALL table, matching on the SERIAL_NUMBER field.
Both methods fail. Any ideas?
I also have issue with the fact that many of standard SQL commands are just
simply not implemented in the SQL implementation in Access 2007 (such as
JOIN, JOIN USING) - is there a list of unsupported SQL commands anywhere?

  #4  
Old February 24th, 2010, 07:25 PM posted to microsoft.public.access.queries
Farkyss
external usenet poster
 
Posts: 25
Default NOT IN (SQL) or Find Unmatched (+ other stuff)

Tried this. Access still ignores the NOT IN clause

"John Spencer" wrote:

Make sure you eliminate any NULLs in the sub-query.

WHERE pd.SERIAL_NUMBER NOT IN
(SELECT SERIAL_NUMBER
FROM INSTALL
WHERE Serial_Number is NOT NULL)

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Farkyss wrote:
Big issue here trying to build a query that lists records whose serial number
DOES NOT appear in another table.
In SQL, would use the condition:
WHERE pd.SERIAL_NUMBER NOT IN (SELECT SERIAL_NUMBER FROM INSTALL)
Access 2007 ignores this caviat and displays all records
Have tried also building the query using the query wizard for finding
unmatched entries, displaying records from my table which do NOT appear in
the INSTALL table, matching on the SERIAL_NUMBER field.
Both methods fail. Any ideas?
I also have issue with the fact that many of standard SQL commands are just
simply not implemented in the SQL implementation in Access 2007 (such as
JOIN, JOIN USING) - is there a list of unsupported SQL commands anywhere?

.

  #5  
Old February 24th, 2010, 07:26 PM posted to microsoft.public.access.queries
Farkyss
external usenet poster
 
Posts: 25
Default NOT IN (SQL) or Find Unmatched (+ other stuff)

Not sure this will achieve what I want. This in mind, find below the full SQL
code:
SELECT po.PURCHASE_DATE, pd.QTY, pd.SERIAL_NUMBER, pa.PART_ID,
pa.DESCRIPTION, c.BUSINESS_NAME, l.BUILDING_NAME, l.STREET, l.LOCALITY,
l.POSTAL_TOWN, l.COUNTY, l.PHONE
FROM (((PURCHASEORDER AS po INNER JOIN PORD AS pd ON
po.SALES_NUMBER=pd.SALES_NUMBER) INNER JOIN PART AS pa ON
pd.PART_ID=pa.PART_ID) INNER JOIN CUSTOMER AS c ON
po.CUSTOMER_ID=c.CUSTOMER_ID) INNER JOIN LOCATION AS l ON
c.BILLING_ADDRESS=l.LOCATION_ID
WHERE pd.SERIAL_NUMBER NOT IN (SELECT INSTALL.SERIAL_NUMBER FROM INSTALL)
AND pd.SERIAL_NUMBER IS NOT NULL;


"Jerry Whittle" wrote:

SELECT DISTINCT Install.SERIAL_NUMBER
FROM Install LEFT JOIN PD
ON Install.SERIAL_NUMBER = PD.SERIAL_NUMBER
WHERE PD.SERIAL_NUMBER Is Null
ORDER BY 1;

Select Install.SERIAL_NUMBER
FROM Install LEFT JOIN PD
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"Farkyss" wrote:

Big issue here trying to build a query that lists records whose serial number
DOES NOT appear in another table.
In SQL, would use the condition:
WHERE pd.SERIAL_NUMBER NOT IN (SELECT SERIAL_NUMBER FROM INSTALL)
Access 2007 ignores this caviat and displays all records
Have tried also building the query using the query wizard for finding
unmatched entries, displaying records from my table which do NOT appear in
the INSTALL table, matching on the SERIAL_NUMBER field.
Both methods fail. Any ideas?
I also have issue with the fact that many of standard SQL commands are just
simply not implemented in the SQL implementation in Access 2007 (such as
JOIN, JOIN USING) - is there a list of unsupported SQL commands anywhere?

  #6  
Old February 24th, 2010, 09:52 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default NOT IN (SQL) or Find Unmatched (+ other stuff)

On Wed, 24 Feb 2010 08:58:07 -0800, Farkyss
wrote:

Big issue here trying to build a query that lists records whose serial number
DOES NOT appear in another table.
In SQL, would use the condition:
WHERE pd.SERIAL_NUMBER NOT IN (SELECT SERIAL_NUMBER FROM INSTALL)
Access 2007 ignores this caviat and displays all records
Have tried also building the query using the query wizard for finding
unmatched entries, displaying records from my table which do NOT appear in
the INSTALL table, matching on the SERIAL_NUMBER field.
Both methods fail. Any ideas?
I also have issue with the fact that many of standard SQL commands are just
simply not implemented in the SQL implementation in Access 2007 (such as
JOIN, JOIN USING) - is there a list of unsupported SQL commands anywhere?


The NOT IN syntax works fine for me. Could you post the actual complete SQL of
your query? Does it have other criteria, particularly OR criteria?
--

John W. Vinson [MVP]
  #7  
Old February 24th, 2010, 10:36 PM posted to microsoft.public.access.queries
Farkyss
external usenet poster
 
Posts: 25
Default NOT IN (SQL) or Find Unmatched (+ other stuff)

SELECT po.PURCHASE_DATE, pd.QTY, pd.SERIAL_NUMBER, pa.PART_ID,
pa.DESCRIPTION, c.BUSINESS_NAME, l.BUILDING_NAME, l.STREET, l.LOCALITY,
l.POSTAL_TOWN, l.COUNTY, l.PHONE
FROM (((PURCHASEORDER AS po INNER JOIN PORD AS pd ON
po.SALES_NUMBER=pd.SALES_NUMBER) INNER JOIN PART AS pa ON
pd.PART_ID=pa.PART_ID) INNER JOIN CUSTOMER AS c ON
po.CUSTOMER_ID=c.CUSTOMER_ID) INNER JOIN LOCATION AS l ON
c.BILLING_ADDRESS=l.LOCATION_ID
WHERE pd.SERIAL_NUMBER NOT IN (SELECT INSTALL.SERIAL_NUMBER FROM INSTALL)
AND pd.SERIAL_NUMBER IS NOT NULL;




"John W. Vinson" wrote:

On Wed, 24 Feb 2010 08:58:07 -0800, Farkyss
wrote:

Big issue here trying to build a query that lists records whose serial number
DOES NOT appear in another table.
In SQL, would use the condition:
WHERE pd.SERIAL_NUMBER NOT IN (SELECT SERIAL_NUMBER FROM INSTALL)
Access 2007 ignores this caviat and displays all records
Have tried also building the query using the query wizard for finding
unmatched entries, displaying records from my table which do NOT appear in
the INSTALL table, matching on the SERIAL_NUMBER field.
Both methods fail. Any ideas?
I also have issue with the fact that many of standard SQL commands are just
simply not implemented in the SQL implementation in Access 2007 (such as
JOIN, JOIN USING) - is there a list of unsupported SQL commands anywhere?


The NOT IN syntax works fine for me. Could you post the actual complete SQL of
your query? Does it have other criteria, particularly OR criteria?
--

John W. Vinson [MVP]
.

  #8  
Old February 25th, 2010, 02:26 PM posted to microsoft.public.access.queries
vanderghast
external usenet poster
 
Posts: 593
Default NOT IN (SQL) or Find Unmatched (+ other stuff)

If Serial_Number are alphanumerical, can you try :


.... where TRIM(pd.serial_number) not in (select TRIM(serial_number) from
install) and ...


Vanderghast, Access MVP


"Farkyss" wrote in message
...
SELECT po.PURCHASE_DATE, pd.QTY, pd.SERIAL_NUMBER, pa.PART_ID,
pa.DESCRIPTION, c.BUSINESS_NAME, l.BUILDING_NAME, l.STREET, l.LOCALITY,
l.POSTAL_TOWN, l.COUNTY, l.PHONE
FROM (((PURCHASEORDER AS po INNER JOIN PORD AS pd ON
po.SALES_NUMBER=pd.SALES_NUMBER) INNER JOIN PART AS pa ON
pd.PART_ID=pa.PART_ID) INNER JOIN CUSTOMER AS c ON
po.CUSTOMER_ID=c.CUSTOMER_ID) INNER JOIN LOCATION AS l ON
c.BILLING_ADDRESS=l.LOCATION_ID
WHERE pd.SERIAL_NUMBER NOT IN (SELECT INSTALL.SERIAL_NUMBER FROM INSTALL)
AND pd.SERIAL_NUMBER IS NOT NULL;




"John W. Vinson" wrote:

On Wed, 24 Feb 2010 08:58:07 -0800, Farkyss
wrote:

Big issue here trying to build a query that lists records whose serial
number
DOES NOT appear in another table.
In SQL, would use the condition:
WHERE pd.SERIAL_NUMBER NOT IN (SELECT SERIAL_NUMBER FROM INSTALL)
Access 2007 ignores this caviat and displays all records
Have tried also building the query using the query wizard for finding
unmatched entries, displaying records from my table which do NOT appear
in
the INSTALL table, matching on the SERIAL_NUMBER field.
Both methods fail. Any ideas?
I also have issue with the fact that many of standard SQL commands are
just
simply not implemented in the SQL implementation in Access 2007 (such as
JOIN, JOIN USING) - is there a list of unsupported SQL commands
anywhere?


The NOT IN syntax works fine for me. Could you post the actual complete
SQL of
your query? Does it have other criteria, particularly OR criteria?
--

John W. Vinson [MVP]
.


  #9  
Old February 25th, 2010, 02:59 PM posted to microsoft.public.access.queries
Farkyss
external usenet poster
 
Posts: 25
Default NOT IN (SQL) or Find Unmatched (+ other stuff)

The values for serial_number in the INSTALL table are looked up from PD, so
physically can't be any different

"vanderghast" wrote:

If Serial_Number are alphanumerical, can you try :


... where TRIM(pd.serial_number) not in (select TRIM(serial_number) from
install) and ...


Vanderghast, Access MVP


"Farkyss" wrote in message
...
SELECT po.PURCHASE_DATE, pd.QTY, pd.SERIAL_NUMBER, pa.PART_ID,
pa.DESCRIPTION, c.BUSINESS_NAME, l.BUILDING_NAME, l.STREET, l.LOCALITY,
l.POSTAL_TOWN, l.COUNTY, l.PHONE
FROM (((PURCHASEORDER AS po INNER JOIN PORD AS pd ON
po.SALES_NUMBER=pd.SALES_NUMBER) INNER JOIN PART AS pa ON
pd.PART_ID=pa.PART_ID) INNER JOIN CUSTOMER AS c ON
po.CUSTOMER_ID=c.CUSTOMER_ID) INNER JOIN LOCATION AS l ON
c.BILLING_ADDRESS=l.LOCATION_ID
WHERE pd.SERIAL_NUMBER NOT IN (SELECT INSTALL.SERIAL_NUMBER FROM INSTALL)
AND pd.SERIAL_NUMBER IS NOT NULL;




"John W. Vinson" wrote:

On Wed, 24 Feb 2010 08:58:07 -0800, Farkyss
wrote:

Big issue here trying to build a query that lists records whose serial
number
DOES NOT appear in another table.
In SQL, would use the condition:
WHERE pd.SERIAL_NUMBER NOT IN (SELECT SERIAL_NUMBER FROM INSTALL)
Access 2007 ignores this caviat and displays all records
Have tried also building the query using the query wizard for finding
unmatched entries, displaying records from my table which do NOT appear
in
the INSTALL table, matching on the SERIAL_NUMBER field.
Both methods fail. Any ideas?
I also have issue with the fact that many of standard SQL commands are
just
simply not implemented in the SQL implementation in Access 2007 (such as
JOIN, JOIN USING) - is there a list of unsupported SQL commands
anywhere?

The NOT IN syntax works fine for me. Could you post the actual complete
SQL of
your query? Does it have other criteria, particularly OR criteria?
--

John W. Vinson [MVP]
.


  #10  
Old February 25th, 2010, 03:06 PM posted to microsoft.public.access.queries
Farkyss
external usenet poster
 
Posts: 25
Default NOT IN (SQL) or Find Unmatched (+ other stuff)

(but no, tried it and no difference)
Would note that my test case involves one record in the INSTALL table that
shares a serial_number with the PORD pd table, so I know that record should
be omitted.
If I remove the subquery from the NOT IN condition and instead replace it
with just a list ("val1","val2") where one of the values is this known
serial_number, then it triggers correctly, so is it maybe that Access 2007 is
not allowing the use of a subquery in a NOT IN clause?
"vanderghast" wrote:

If Serial_Number are alphanumerical, can you try :


... where TRIM(pd.serial_number) not in (select TRIM(serial_number) from
install) and ...


Vanderghast, Access MVP


"Farkyss" wrote in message
...
SELECT po.PURCHASE_DATE, pd.QTY, pd.SERIAL_NUMBER, pa.PART_ID,
pa.DESCRIPTION, c.BUSINESS_NAME, l.BUILDING_NAME, l.STREET, l.LOCALITY,
l.POSTAL_TOWN, l.COUNTY, l.PHONE
FROM (((PURCHASEORDER AS po INNER JOIN PORD AS pd ON
po.SALES_NUMBER=pd.SALES_NUMBER) INNER JOIN PART AS pa ON
pd.PART_ID=pa.PART_ID) INNER JOIN CUSTOMER AS c ON
po.CUSTOMER_ID=c.CUSTOMER_ID) INNER JOIN LOCATION AS l ON
c.BILLING_ADDRESS=l.LOCATION_ID
WHERE pd.SERIAL_NUMBER NOT IN (SELECT INSTALL.SERIAL_NUMBER FROM INSTALL)
AND pd.SERIAL_NUMBER IS NOT NULL;




"John W. Vinson" wrote:

On Wed, 24 Feb 2010 08:58:07 -0800, Farkyss
wrote:

Big issue here trying to build a query that lists records whose serial
number
DOES NOT appear in another table.
In SQL, would use the condition:
WHERE pd.SERIAL_NUMBER NOT IN (SELECT SERIAL_NUMBER FROM INSTALL)
Access 2007 ignores this caviat and displays all records
Have tried also building the query using the query wizard for finding
unmatched entries, displaying records from my table which do NOT appear
in
the INSTALL table, matching on the SERIAL_NUMBER field.
Both methods fail. Any ideas?
I also have issue with the fact that many of standard SQL commands are
just
simply not implemented in the SQL implementation in Access 2007 (such as
JOIN, JOIN USING) - is there a list of unsupported SQL commands
anywhere?

The NOT IN syntax works fine for me. Could you post the actual complete
SQL of
your query? Does it have other criteria, particularly OR criteria?
--

John W. Vinson [MVP]
.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.