473,386 Members | 1,969 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,386 software developers and data experts.

finding not equal data sets

hi everybody,

i have a rather short and possibly easy question: i have two tables
and want to find all unequal datasets. for instance like this: i have
a table A holding fields id and x and a table B holding id and y. now
i want to show a table C holding all ids except the intersection of
both.

I tried something like

SELECT A.id, B.id
from A, B
WHERE A.id<>B.id;

it didnt let me use "group by", I didnt quite get why.

Please help, also contributions without sql but something over the gui
(drag and drop) are welcome!

thank you.

yours, Kenny Ajram
Jan 15 '08 #1
1 3113
On Jan 15, 9:25*am, kenny Ajram <kenny1...@web.dewrote:
hi everybody,

i have a rather short and possibly easy question: i have two tables
and want to find all unequal datasets. for instance like this: i have
a table A holding fields id and x and a table B holding id and y. now
i want to show a table C holding all ids except the intersection of
both.

I tried something like

SELECT A.id, B.id
from A, B
WHERE A.id<>B.id;

it didnt let me use "group by", I didnt quite get why.

Please help, also contributions without sql but something over the gui
(drag and drop) are welcome!

thank you.

yours, Kenny Ajram
If you only care about x and y values themselves and not about the
(id, x), (id, y) combinations:

For table A with X and table B with Y,

qryXOR:
SELECT X FROM A LEFT JOIN B ON A.X = B.Y WHERE B.Y IS NULL UNION
SELECT Y FROM B LEFT JOIN A ON B.Y = A.X WHERE A.X IS NULL;

It's a UNION of two unmatched queries.

A
ID AutoNumber
X Dbl
ID X
1 1
2 2
3 3
4 4
5 5
6 6
7 7

B
ID AutoNumber
Y Dbl
ID Y
1 4
2 5
3 6
4 7
5 8
6 9

!qryXOR:
X
1
2
3
8
9

If you only care about the ID values and not the (id, X), (id, Y)
combinations:

SELECT A.ID FROM A LEFT JOIN B ON A.ID = B.ID WHERE B.ID IS NULL UNION
SELECT B.ID FROM B LEFT JOIN A ON B.ID = A.ID WHERE A.ID IS NULL;

yields

ID
7

If you care about the (id, x), (id, y) combinations, perhaps use:

SELECT DISTINCTROW A.ID, X FROM A LEFT JOIN B ON A.X = B.Y AND A.ID =
B.ID WHERE B.Y IS NULL UNION SELECT DISTINCTROW B.ID, Y FROM B LEFT
JOIN A ON B.Y = A.X AND A.ID = B.ID WHERE A.X IS NULL;

After changing the first three Y values in B to 1, 2 and 3, I get:

ID X
4 4
4 7
5 5
5 8
6 6
6 9
7 7

Each unmatched query can use GROUP BY. Please include an example of
the grouping you want if you need more help.

James A. Fortune
CD********@FortuneJames.com
Jan 15 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: giampiero mu | last post by:
hi everyone my target is implement a function controlla(string - a binary string-) that check if there is in a string two equal not overlapping subsequences at least of length limitem: my...
2
by: TadPole | last post by:
Hi all, My main problems are::::::::: 1. Set a value within a block container that can be used and changed by subsequent templates/block-containers/tables etc.. 2. get/determine/find the...
2
by: User 2084 | last post by:
Hello all. I'm an access newbie trying to learn how to do basic database data manipulations. I had a hard time searching the archives on this question as I don't really know what I'm looking for in...
5
by: trint | last post by:
I know that this function IS in this dll that comes with windows xp that allows bidirectional printing (you can search "bidispl.dll" on MSDN). However, I keep getting the same error all day, go to...
2
by: Lior | last post by:
Hi, I have an ASP.NET website that crashes under heavy load. I use a SQL Server DB. I get around 5500 hits per day. I keep getting the timeout expieried connection pool error. Sometimes it even...
3
by: Suresh Jeevanandam | last post by:
I have a list of sets in variable lsets . Now I want to find the intersection of all the sets. r = lsets for s in r: r = r & s Is there any other shorter way?
17
by: Mark A | last post by:
DB2 8.2 for Linux, FP 10 (also performs the same on DB2 8.2 for Windoes, FP 11). Using the SAMPLE database, tables EMP and EMLOYEE. In the followng stored procedure, 2 NULL columns (COMM) are...
6
by: Martin | last post by:
Hi I need to maintain a <setof pointers to objects, and it must be sorted based on the values of pointed objects, not pointer values. I can achieve this easily by defining my own comparing...
14
by: serge calderara | last post by:
Dear all, What is the proper way to check if two object are equal ? I do not mean equal on Object type only but also object value's thnaks for help regards serge
5
by: davenet | last post by:
Hi, I'm new to Python and working on a school assignment. I have setup a dictionary where the keys point to an object. Each object has two member variables. I need to find the smallest value...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.