#100CodeExamples
Updating a Table with the Values of a Different One
I am working professionally with databases for over 15 years now and have a huge focus on Oracle – but I really keep forgetting how to update a table with values of a different one (this is one thing which is so much easier in SQL Server by the way).
Therefore let’s assume we have a table containing planets and one containing garrisons which are on these planets.
Garrison ID | Planet Name | Planet Faction |
1 | Korriban | imperium |
2 | Korriban | imperium |
3 | Dromund Kaas | imperium |
4 | Hoth | republic |
We would now like to have a new column in the garrisons table which can contain a name.
alter table garrisons add name varchar2(300)
The imperial side now has a request to update all their garrisons with a name according to this schema: <PlanetName> (<Garrison ID>)
(more…)