Djkjk
Djkjk

Reputation: 1

Fill a blank field access 2010 sql

Problem: there is a table T1. I need to write a query (sql access 2010): if field F2 is empty, then the value of the F1 field must be filled with the value of the field F2. If tried to write a query, don't work it:

SELECT T1.[Code], T1.[F1], T1.[F2]
UPDATE IIF(F2 = "" ; [F2]=[F1] ; [F2]=[F2] )
FROM T1;

Link in the image (I can't attach an image here): https://i.imgsafe.org/3862623.png

Upvotes: 0

Views: 36

Answers (2)

Gustav
Gustav

Reputation: 55806

It looks like you just wish to list the records with no blanks - then it is a simple select query:

SELECT T1.[Code], T1.[F1], Nz(T1.[F2], T1.[F1]) As FX
FROM T1;

Upvotes: 0

Andre
Andre

Reputation: 27634

First, you can't mix SELECT and UPDATE. All you need is UPDATE.

I think you simply need:

UPDATE T1
SET F2 = F1
WHERE F2 IS NULL OR F2 = ""

Upvotes: 1

Related Questions