Access IFf Query

database-designupdate

I'm new and just starting out at creating databases so I apologise if noob question.

What I am trying to do is update my Staff table to show that "Sarah Avon" has married and her new last name is changed to "Tyne"

enter image description here

I have used in SQL view the following code to do this.

enter image description here

However when running the query it leaves all cells blank as shown below. What I wish to happen is Sarah’s last name is updated from Avon to Tyne.

enter image description here

Can anyone bring some light on the subject as to where I have gone wrong?

Thank you all for your time.

Best Answer

I don't know much of T-SQL but I believe that to compare strings you need the logical operator AND. Try this:

UPDATE StaffCopy SET StaffCopy.LastName=IIF(([LastName]='Avon' AND [FirstName]='Sarah'), 'Tyne', [LastName]);