I know this might be a very simple one, but yet I can't figure that one out!
How do I get data from one table that are not in another?

Let's say Table ServerA has: IP, User, Password, Table ServerB has: IP, CanConnect.
If ServerA has 20 rows and ServerB has 13 rows. How do I get those 7 rows that are in ServerA but not in ServerB?

Here's what I got, but it's not giving me what I want:

SELECT ServerA.*
FROM ServerA WHERE NOT EXISTS (
SELECT * FROM ServerB
WHERE ServerA.IP = ServerB.IP)
SELECT ServerA.*
FROM ServerA LEFT JOIN ServerB ON ServerB.IP = ServerA.IP
WHERE ServerB.IP IS NULL

Any help would be much appreciated!

Recommended Answers

All 2 Replies

Both of these worked fine when I tested them. The only thing I can think of is that there is some sort of datatype mismatch, or appended spaces, non-printable characters (think "TAB" or "CRLF").

What does your data look like?

That was it BitBlt! non-printable characters....I imported the data originally from a text file into a table. By just looking at it, you'd think it matched...
That one caused me grief :)
Thanks!!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.