Reputation: 1
I am trying to Update a table in Access using SQL. I need to update a column in one table to be UPDATED if a column in another table is TRUE.
I have tried writing my own code but to no avail!
UPDATE table1, table2
SET table1.ReportName = "UPDATED"
WHERE ((table1.Name=table2.name) AND ((table2.Ind)="TRUE"));
I get an error that says: Data Type mismatch in criteria expression.
Upvotes: 0
Views: 33
Reputation: 164184
Use EXISTS:
UPDATE table1
SET table1.ReportName = 'UPDATED'
WHERE EXISTS (
SELECT 1 FROM table2
WHERE table2.Name = table1.name AND table2.Ind = 'TRUE'
)
If the data type of table2.Ind
is Boolean (Yes/No)
then:
UPDATE table1
SET table1.ReportName = 'UPDATED'
WHERE EXISTS (
SELECT 1 FROM table2
WHERE table2.Name = table1.name AND table2.Ind = TRUE
)
Upvotes: 1