Compare 2 fields and then ouput 1 of 2 fields

S

Steve

HI

I wanted to compare 2 fields in different tables and take this field
from 1 table or another
depending on some criteria.

Both tables have Part Name and the Part Description.
I would do a Left Join (Table1 (master table) -> Table2)on Part Name and
I want to output
The Part Name and The Part Description. The Part Description
I want output would be from Table2 Unless it is Null then I would take
the PArt Description
from Table 1

Any Help would be appreciated

Thanks
Steve


Table1
part name Part description
Part1 Part1 Desc
Part2 Part2 Desc
Part3 Part3 Desc


Table2
part name Part Description
Part1 Part1 Updated Desc
Part2
Part3 Part3 Updated Desc
 
B

Brian Camire

You might enter an expression like this in the Field row of an empty column
in the grid in query design view:

Nz([Table2].[Part Description], [Table1].[Part Description])

Check the help for more information on the Nz function.
 
J

John Vinson

Both tables have Part Name and the Part Description.
I would do a Left Join (Table1 (master table) -> Table2)on Part Name and
I want to output
The Part Name and The Part Description. The Part Description
I want output would be from Table2 Unless it is Null then I would take
the PArt Description
from Table 1

The NZ() function can be helpful here:

SELECT Table1.PartName,
NZ(Table2.PartDescription, Table1.PartDescription) AS Desc
FROM Table1 LEFT JOIN Table2 ON Table1.PartName = Table2.PartName;
 

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