1 Reply Latest reply: Aug 2, 2014 12:40 AM by osgood_ RSS

    SQL Joining

    ottz0 Community Member

      I'm just starting out in SQL, so this is a trusty forum for me to use.


      I have a database with 3 tables (states,regions,cities)

       

      States hold a state_id and the state_abr(NSW,QLD,VIC)

      Regions hold the region_id and a foreign key links the regions to the states via the state_id

      Cities hold the city_id and a foreign key links the cities to the regions via the region_id.

       

      How would I get the state_abr to show in my cities table seeing that it is stored in the states table?


      Do I join or create a foreign key straight from the cities to the state, that then become unrelated to the regions?


      Or do I obtain the state_id from The regions table which is then linked to the state table?


      Its like I have to do a join to the regions then to join to get the state?A join on a join

       

      Thanks