[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

select query

Hi,
I have two tables, tblA and tblB both has same fields. tblA is containing old records and tblB is containing new records.

1. Now I want a select query which will be producing all records from tblB where tblA.ERNO = tblB.ERNO And tblA.EID = tblB.EID

2. I want another query which will be producing all records from tblB where the records does not matches  tblA.ERNO = tblB.ERNO And tblA.EID = tblB.EID

I am using MS ACCESS 2003.
0
suvmitra
Asked:
suvmitra
1 Solution
 
jtdebeerCommented:
Use the JOIN keyword.
More info at http://www.w3schools.com/Sql/sql_join.asp
0
 
Stephan_SchrandtCommented:
Create a new query, switch to SQL view and paste the lines (one per query)

1. Select tblA.*, tblB.* FROM tblA Inner join tblB ON tblA.ERNO = tblB.ERNO And tblA.EID = tblB.EID

2. Select tblB.* FROM tblB LEFT join tblA ON tblB.ERNO = tblA.ERNO And tblB.EID = tblA.EID WHERE nz(tblA.EID,"") = ""


0
 
tigin44Commented:


try theese
1 query
SELECT tblB.*
FROM tblA
		INNER JOIN tblB ON tblA.ERNO = tblB.ERNO And tblA.EID = tblB.EID
		
2 query
SELECT tblB.*
FROM tblB
WHERE NOT EXISTS (SELECT NULL FROM tblB WHERE tblA.ERNO = tblB.ERNO And tblA.EID = tblB.EID)

Open in new window

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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