473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

retrieve Identical records between two sub query

I use below query to retrieve unmatch record

SELECT *
FROM Emp1
WHERE NOT exists
(SELECT *
FROM Emp2
WHERE Emp1.Eid=Eid and
Emp1.Ename=Ename)



but My query display record if there is any execess records in frist table (emp1).
but i need execess records from both the tables
Oct 13 '07 #1
1 991
iburyak
1,017 Expert 512MB
You can do this :

Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM Emp1
  3. WHERE NOT exists
  4. (SELECT *
  5. FROM Emp2
  6. WHERE Emp1.Eid=Eid and
  7. Emp1.Ename=Ename)
  8.  
  9. Union
  10.  
  11. SELECT *
  12. FROM Emp2
  13. WHERE NOT exists
  14. (SELECT *
  15. FROM Emp1
  16. WHERE Emp2.Eid=Eid and
  17. Emp2.Ename=Ename)
or this:

Expand|Select|Wrap|Line Numbers
  1. select a.*, b.*
  2. from Emp1 a
  3. full join Emp2 b on a.Eid = b.Eid and a.Ename = b.Ename
  4. where a.Eid is null or b.Eid is null

Good Luck.
Oct 13 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Andre Doreid Berro | last post by:
Greetings All I have requested help before and I really need your help in this. I am working on an Access database of contacts. I have plenty of records but plenty of them are almost...
1
by: Nicolae Fieraru | last post by:
Hi All, I have a table with the following information: ID, Name, Address, Field4 In this table it happens to have duplicate records with identical Name and Address but different content in...
12
by: jaYPee | last post by:
I have currently using a dataset to access my data from sql server 2000. The dataset contains 3 tables that is related to each other. parent/child/grandchild relationship. My problem is it's very...
48
by: phillip.s.powell | last post by:
MySQL 3.23.58 - 4.0.17 (yep, several database server instances, don't ask) I have database Spring with table Students I have database Summer with table Students I am tasked to produce a...
5
by: KitKat | last post by:
I've got two queries; one is a modification of an older query; the other I created from scratch. The old one is about 5 copies down the road from something that has been expandable when I'm in...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
0
by: padhuwork | last post by:
Hi, I want to create a Windows DLL using VC++ 6.0 which connects to SQL Server. After establishing the connection, I want to retrieve records from table (query) and out put the recordset to a...
4
by: LetMeDoIt | last post by:
Greetings, I'm using ASP to retrieve from MSSQL and I then populate a table. After several months of successfull retrieves, this same code now bombs out. It turns out that if I clear out from...
4
by: questionit | last post by:
How do i retreive 10 rows from a table using SQL SELECT Names from Customers... how do i change it to retrieve only 'n' number of rows? Please suggest an easy method Thanks
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.