Should I be using a UNION query?

  • Thread starter Thread starter danbuscaglia
  • Start date Start date
D

danbuscaglia

I have two tables. One is called tblImport and the other
tblVacationCerts

I have a list of Vacation Cert #'s in tblVacationCerts, and for every
order that gets imported into tblImport, I need to assign 1 Vacation
Cert # and then never use it again. I dont know how to use a Union
Query to update the Vacation # into tblImport as well as flag it as
used in tblVacationCert.

1) is using a union query as source in an update query the right way to
do this?

2) if not, can anyone help me figure out how to tackle this problem.

Excuse my novice, I am an undergrad doing IT work for a small business
with no other programmers around.
 
From what you're describing, I don't see any way to use a Union query.

However, do you really need to flag the Vacation # as used in
tblVacationCert? You could create a query that joins the two tables, only
returning those rows in tblVacationCert that don't have a matching row in
tblImport, and use that query wherever you would otherwise have used
tblVacationCert.

Something like the following should work:

SELECT CertNb
FROM tblVacationCert
LEFT JOIN tblImport
ON tblVacationCert.CertNb = tblImport.CertNb
WHERE tblImport.CertNb IS NULL
 
Back
Top