0

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.

1
  • Welcome to SO! Please take the tour and read How to Ask! Commented Aug 9, 2019 at 14:42

1 Answer 1

1

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
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.