Introduction
The very basics
Infinite looping
Processing graphs with recursive CTE
26. Traveling salesman 1
Summary

Instruction

Okay! Quite an impressive query that was, wasn't it? Let's build it step by step from scratch now.

Exercise

We start in London, so let's show the information for London first. We need the following columns:

  • path - for now, it's simply the city name,
  • lat,
  • lon,
  • total_distance - the total distance travelled between cities - for now equal to 0.0,
  • count_places the number of cities visited - equal to 1 at this point.

All the information can be found in table city.