I've been struggling with my query and don't know what is wrong with it. I am not an advanced SQL user, but I have some understanding of SQL.
I have two tables and I am trying to update one field with the field from the other table. They do not have a unique identifier in each, so they need to be matched with three fields (HoleID, From, To), especially because table LEAPFROG_Lithology has more records that do not have the same From/To than in the Lithology table.
I have looked for questions asked on similar subject, and tried different variant of my query, but none work and it always asks me to "Enter parameter value". I tried with an inner joint like in this one and one, but it did not work.
Here is what I tried:
Version 1
Update LEAPFROG_Lithology
SET LEAPFROG_Lithology.Primary_litho = (
SELECT Lithology.Primary_litho
FROM Lithology
RIGHT JOIN LEAPFROG_Lithology ON (
Lithology.[HoleID] = LEAPFROG_Lithology.[HoleID] and
Lithology.[From_m] = LEAPFROG_Lithology.[From_m] and
Lithology.[To_m] = LEAPFROG_Lithology.[To_m]))
Where LEAPFROG_Lithology.Primary_litho is null ;
Version 2 (tried with an INNER JOIN as well)
Update LEAPFROG_Lithology
LEFT JOIN Lithology ON (
LEAPFROG_Lithology.[HoleID] = Lithology.[HoleID] and
LEAPFROG_Lithology.[From_m] = Lithology.[From_m] and
LEAPFROG_Lithology.[To_m] = Lithology.[To_m])
SET LEAPFROG_Lithology.Primary_litho = Lithology.Primary_litho
Where LEAPFROG_Lithology.Primary_litho is null ;
I tried with [ ] everywhere, with none. It doesn't make a difference.
Can someone tell me what am I doing wrong? Thanks!