SQL statement/joining tables when unequal

N

non-programmer

I'd like to join two tables, but I don't have the option to display only
those entires that are not in the second table. I've been trying without any
success to write an SQL statement to produce only those entries that are in
one table and not the other.

I've tried just modifying an inner join to be "not equal" instead of "equal":

SELECT
FROM [Media Outlet] INNER JOIN [Local Media Outlets] ON [Media
Outlet].[Media Outlet] <> [Local Media Outlets].[Local Media Outlets];

And I get this error message: The SELECT statement includes a reserved word
or an argument name that is misspelled or missing, or the punctuation is
incorrect.

I've also tried crafting my own SQL statement (quite a feat for a
non-programmer):

SELECT DISTINCT [Media Outlet]
FROM [Media Outlet]
WHERE [Media Outlet].[Media Outlet] <> [Local Media Outlets].[Local Media
Outlets];

And it keeps asking for the parameter value of [Local Media Outlets].[Local
Media Outlets].

I don't know how much more information you might need to see my problem, but
these are two separate (completely unconnected tables) with two columns each.
In Media Outlet, one is the ID and the other is Media Outlet. In Local Media
Outlets, one is the ID and the other is Local Media Outlets. I've tried
adding paranthesis in every imaginable combination and it doesn't seem to
help.

Thank you for any help you can give me
 
S

Stefan Hoffmann

hi,

non-programmer said:
I've tried just modifying an inner join to be "not equal" instead of "equal":
SELECT
FROM [Media Outlet] INNER JOIN [Local Media Outlets] ON [Media
Outlet].[Media Outlet] <> [Local Media Outlets].[Local Media Outlets];
I'm not sure what you like to get as result, but try this one:

SELECT *
FROM [Media Outlet], [Local Media Outlets]
WHERE [Media Outlet].[Media Outlet] <>
[Local Media Outlets].[Local Media Outlets];

or

SELECT *
FROM [Media Outlet]
LEFT JOIN [Local Media Outlets]
ON [Media Outlet].[Media Outlet] =
[Local Media Outlets].[Local Media Outlets]
WHERE IsNull([Local Media Outlets].[Local Media Outlets])


mfG
--> stefan <--
 
N

non-programmer

Thank you, Stefan! The second one worked! It still gives me the other columns
with no data, but that doesn't really matter, since I'd just be using the one
to filter out the next query I need to build with it.
Thank you!
Heather

Stefan Hoffmann said:
hi,

non-programmer said:
I've tried just modifying an inner join to be "not equal" instead of "equal":
SELECT
FROM [Media Outlet] INNER JOIN [Local Media Outlets] ON [Media
Outlet].[Media Outlet] <> [Local Media Outlets].[Local Media Outlets];
I'm not sure what you like to get as result, but try this one:

SELECT *
FROM [Media Outlet], [Local Media Outlets]
WHERE [Media Outlet].[Media Outlet] <>
[Local Media Outlets].[Local Media Outlets];

or

SELECT *
FROM [Media Outlet]
LEFT JOIN [Local Media Outlets]
ON [Media Outlet].[Media Outlet] =
[Local Media Outlets].[Local Media Outlets]
WHERE IsNull([Local Media Outlets].[Local Media Outlets])


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top