Displaying results from a comparison in query

webmagic

Registered User.
Local time
Today, 11:22
Joined
Jul 18, 2008
Messages
61
Hello,
I just figured out how to do a comparison and get only the results of those that are not equal, but I have several more fields that I need to include if the name fields from the table are the same. I have tried a few things and keep getting errors with syntax. Any help is appreciated.

Select Table1.name from Table1 LEFT JOIN Table2 ON (Table1.name = Table2.name)
WHERE (((Table2.name) is Null))
UNION Select Table2.name from Table1 RIGHT JOIN Table2 ON (Table1.name = Table2.name)
WHERE (((Table1.name) is Null));
 
If you're only looking for those with a match, why not use an INNER JOIN?

SELECT TABLE1.FIELD1, TABLE2.FIELD2
FROM TABLE1 INNER JOIN TABLE2 ON TABLE1.FIELD1=TABLE2.FIELD1
 
Web,

I just see mismatched parentheses:

Code:
Select Table1.name 
From Table1 LEFT JOIN Table2 ON 
       Table1.name = Table2.name
WHERE Table2.name is Null
UNION Select Table2.name 
from Table1 RIGHT JOIN Table2 ON 
      Table1.name = Table2.name
WHERE Table1.name is Null;

Wayne
 
The code that I used above works. I only want the fields that do not match and it works for that. What I need is to include the other fields that are attached to those fields.

I am updating a table from orders that were processed from days before. I don't want to include the order numbers that are already in that table only the new ones. I hope this makes sense.
 
Would the following code be what you want?

Code:
SELECT Table1.*
FROM Table1 LEFT JOIN Table2 ON Table1.FieldtoJoin = Table2.FieldtoJoin 
WHERE (((Table2.FieldtoJoin) Is Null));

I think this will give the new (complete) entries from Table1 and you can append them to Table2
 
Web,

I think you're talking to Pat ... she's good!

Wayne
 

Users who are viewing this thread

Back
Top Bottom