View Full Version : bodged query - better way


garethl
06-27-2007, 02:50 AM
hello

once again i've fixed something up to work but my inexperience leads me to wonder if there is a better way

what i am trying to achieve is to select all the records from a table which are new - so i have a table of 'newJobs' which i got by importing an excel file and each one of those jobs comes under a submission

i have a submissions table so i need to select all of the submissionRefs which aren't in the submissions table and append them to it

i used the FindUnmatched wizard to build a new temporary table containing all the records which were in NewJobs but not in Submissions and now i need to filter that further because the same submissions refs occur multiple times in that table

to get each new submission once and once only in my results (so that i can then take the output of this query and use it to append the submissions table) i am using the following sql

SELECT First(TBL_TmpNewSubmissionsFromMaster.SubmissionRe ference) AS [SubmissionReference Field], Count(TBL_TmpNewSubmissionsFromMaster.SubmissionRe ference) AS NumberOfDups
FROM TBL_TmpNewSubmissionsFromMaster
GROUP BY TBL_TmpNewSubmissionsFromMaster.SubmissionReferenc e
HAVING (((Count(TBL_TmpNewSubmissionsFromMaster.Submissio nReference))>0));

it works (and perhaps i shouldn't really worry beyond that) i got this by using the wizard to design a find duplicates then editing the sql so that count was > 0 instead of > 1

i'm just wondering if i'm missing an obvious easy way or whether there is something in this which is going to turn round and bite me later on!