Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query - comparing content of two fields

Status
Not open for further replies.

n0nick

Programmer
Apr 28, 2005
32
NO
I want to write a SQL query that compare content of two fields, and if the content is different, content from Table 2 is going to be updated to Table 1.

This is working great with this SQL query:

UPDATE Table2 INNER JOIN Table1 ON Table2.ID = Table1.ID SET Table1.Adress = [Table2].[Adress]
WHERE (((Leverandører.Adress)<>[Table2].[LevAdresse2]));

But this query only works if both fields are NOT empty. Lets say Table1 field is empty, and Table2 field is not empty for the same ID, then it should copy content from Table2 to Table1, but it doesn't do that..can anyone help??
 
WHERE Nz(Leverandører.Adress)<>[Table2].[LevAdresse2];

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you very much for quick answer ;) Have a very nice day
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top