ms access - SQL Update query on query result -
i have 2 tables like:
table 1
sid sdefinition cvalue 4057 s1 32 4058 s2 4059 s3 6 4060 s4
mapping_tbl
sid sinid ecfid sid-sinid 4057 1099 4027e 1099_4057 4058 1099 4027e 1099_4058 4059 1121 4003e 1121_4059 4060 1121 4003e 1121_4060
query1
select mapping_tbl.sid, table1.sdefinition, table1.cvalue table1 inner join mapping_tbl on table1.sid= mapping_tbl.sid;
query1(result)
sid sdefinition cvalue 4057 s1 32 4058 s2 4059 s3 6 4060 s4
i have situation wanted update query table (query1) i.e set field(cvalue) 0 if contains null. using update query like
update query1 set cvalue = 0 cvalue null;
the query table (query1) gets updated , sets cvalue 0 if contains nulls, , updates(set 0) table1 cvalues null.
how can avoid updating table1? suggestions.
it seems don't want change values stored in table, , want query display 0 when cvalue null. can have query substitute 0 null in result set (without changing values in table) ...
select m.sid, t.sdefinition, iif(t.cvalue null, 0, t.cvalue) [cvalue] table1 t inner join mapping_tbl m on t.sid= m.sid;
for query in access session, use vba nz()
function ...
select m.sid, t.sdefinition, nz(t.cvalue null, 0) [cvalue] table1 t inner join mapping_tbl m on t.sid= m.sid;
i used aliases table names. don't need them null substitution work. prefer aliases.
Comments
Post a Comment