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  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > How do I?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-03-02, 07:20
MartinDeSouza MartinDeSouza is offline
Registered User
 
Join Date: Jul 2002
Posts: 4
Talking How do I?

Does anyone know how to write a query that will tell me which fields are left remaining, in a comparison between a master table and a lesser table which contains the same field (account number)?
The lesser table gradually fills up with the account numbers that are on the master as visits to the sites are completed.
I am using MS Access for this.
I can't remember how to do this.
My brain has turned to cheese.
Reply With Quote
  #2 (permalink)  
Old 09-03-02, 07:25
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
select stuff from master
where not exists
(select 1 from lesser
where acctnum=master.acctnum)

you could also try

select stuff from master
except
select stuff from lesser

which is standard sql, but i have no idea if access supports this yet -- access 97 didn't

rudy
http://rudy.ca/
Reply With Quote
  #3 (permalink)  
Old 09-10-02, 11:05
Sef Sef is offline
Registered User
 
Join Date: Aug 2002
Location: Kampala, Uganda - East Africa
Posts: 13
Use this:

SELECT master.fieldx
FROM master
WHERE master.fieldx NOT IN
(SELECT corresponding_field_in_lesser_table
FROM lesser)

Make sure that u are reffering to the same field from both tables. As in, may be u should use the account numbers field from both tables.


The 1st SELECT statement picks records that are not in the 2nd SELECT statement.
The 2nd SELECT statement picks up all the data from the lesser table.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On