hanchilicious
Programmer
Hi,
This is my update statement in SQL 8:
The trouble is that the my_other_table does not contain all the sales ids that my_table contains. So, using it as a reference leads to this kind of thing:
Because my_other_table only contains ER19, this is the only value that gets mapped successfully, meaning the other values don't get mapped to null.
What I want to happen is this:
where if there's no corresponding value in my_other_table, then my_table keeps it's original value.
What's a sensible way to achieve this, please?
Thanks for reading.
This is my update statement in SQL 8:
Code:
update my_table
set sales_district_id =
(select salesgroup from my_other_table where my_other_table.salesid = my_table.sales_id)
The trouble is that the my_other_table does not contain all the sales ids that my_table contains. So, using it as a reference leads to this kind of thing:
Code:
OLDID MAPID MAPVAL
DS12 NULL NULL
ED18 NULL NULL
ED19 ER19 ER04
BG28 NULL NULL
BG32 NULL NULL
BG33 NULL NULL
BG38 NULL NULL
What I want to happen is this:
Code:
OLDID MAPID MAPVAL
DS12 NULL DS12
ED18 NULL ED18
ED19 ER19 ER04
BG28 NULL BG28
BG32 NULL BG32
BG33 NULL BG33
BG38 NULL BG38
What's a sensible way to achieve this, please?
Thanks for reading.