• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

How to query two tables and merge the results?

I have two tables in Access, table A and table B.  I want to query both tables, find the like records and unlike records, and then display the results in Excel.  If the record exists in both tables, I only want to show the record from table A.

Can someone provide a code example for me to go by?
0
g118481
Asked:
g118481
  • 2
1 Solution
 
pinaldaveCommented:
Hi g118481,
 
you should post this question in mssql area they will be able to give you quick reply.

Regards,
---Pinal
0
 
mrichmonCommented:
Actually you should post in the Accesss area - not MySql - and you need to post more information such as what do the tables look like?  What is the filed that they have in common that you want to compare.  DO you want to compare just existance of a single field or differences accross records?
0
 
g118481Author Commented:
MySQL and Access forums would not be able to help with how and where to us CFLOOP nor any CF conditional statements for this request.

I want to query table A and table B, find the like records in both and the records that are not alike, but only display the like records for table A and display the records that are not alike.  So, if a record exist in table B, but not in table B, then display it.  If a record exist in table A and table B, the display the record in table A, but not the record in table B.

Both tables have like named fields.  Here are the field names:
id
codenumber
codephase
codetotal
codeactuals
codemonth
codeid
codesubline
icodenumber
codepace


0
 
mrichmonCommented:
Yes, but once you have the queries that pull what you want you can easily display them.

Do you want to compare just existance of a single field or differences accross records?

Try something like this and see if it is waht you want....


SELECT *
FROM table1 t1
LEFT OUTER JOIN table2 t2
ON t1.id = t2.id
t2.id IS NULL

this will pull all records that are in table 1 that  are NOT in table 2.  It works in SQL, but may need a bit of modification depending on the version of access....
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now