Reputation: 15
wondering if there is a way do this kind of if in SELECT block.
SELECT
[ if Table1.field == NULL
then
Table2.field
else
Table3.field
] as OutputField
i checked the IFF and CASE-WHEN, doesn't seem to support this.
Upvotes: 0
Views: 35
Reputation: 520859
On MS Access database, you would use IIF
along with ISNULL
:
SELECT
IIF(ISNULL(Table1.Field), Table2.Field, Table3.Field) AS OutputField
FROM yourTable
Upvotes: 1
Reputation: 204746
You need to use IS
for NULL
checks:
select case when Table1.field IS NULL
then Table2.field
else Table3.field
end as OutputField
from ...
Upvotes: 1