I need an if-statement that creates a field called “part_ID”. This field takes the field “p.ID” and looks it up in “a.Part_ID”. If the part_ID is not null in “a.Part_ID”, then the part ID should remain unchanged and just be “a.Part_ID”. If the part ID is null, then it should lookup the part ID in “b.Part_ID_Not_cataloged” and if the part ID is listed, then it should substitute it with “b.related_Part_ID_in_catalog”.
SELECT a.Part_ID, p.ID, b.Part_ID_Not_cataloged, b.related_Part_ID_in_catalog
FROM (SYSADM_PART AS p
LEFT JOIN tbl_concatenated_data_view_only AS a ON p.ID = a.Part_ID)
LEFT JOIN tbl_Part_ID_Not_in_catalog_entry AS b ON p.ID = b.Part_ID_Not_cataloged;
You will need to use IIF