Question

I'm a bit of a noobie when it come to SQL, I'm using Access 2013 and I'm trying to update a date field in one table, using id numbers from a different table to only update specific ones.

The query I have is:

UPDATE Leadsavailable SET First_Usage_Date = '23/04/2014'
from leadsavailable r
inner join WorkingTable_GOSH g
    on g.[lead number] = r.[Lead number] 
where g.Type = 'GOSH'

but I keep getting errors and don't know why.

Any help would be much appreciated

Was it helpful?

Solution 2

Try this sorry im in a mobile:

UPDATE Leadsavailable A
INNER JOIN WorkingTable_GOSH B
ON A.[lead number] = B.[Lead number]
Set A.[First_Usage_Date] = '23/04/2014'
Where B.Type = 'GOSH';

OTHER TIPS

Assuming my understanding of your requirement is correct, and you want to update all records in Leadsavailable that have a matching record in WorkingTable_GOSH with Type = 'GOSH' then this will give you the results you're after:

UPDATE Leadsavailable 
SET First_Usage_Date = '23/04/2014'
WHERE [lead number] in (SELECT [Lead number] 
                        FROM WorkingTable_GOSH 
                        WHERE Type = 'GOSH')

The mistake in your original query is having the table name listed twice. It should look liek this:

UPDATE r
   SET First_Usage_Date = '23/04/2014'
  FROM leadsavailable r
inner join WorkingTable_GOSH g on g.[lead number] = r.[Lead number] 
where g.Type = 'GOSH'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top