2 Suburb_id's in same table...

Results 1 to 2 of 2

Thread: 2 Suburb_id's in same table...

  1. #1
    Join Date
    Dec 1969

    Default 2 Suburb_id's in same table...

    Hi,<BR><BR>I have a table for addresses - each user can have two addresses therefore they have suburb_id_1 and suburb_id_2 as two different fields that both relate to the same table (suburb_t).<BR><BR>However, you aren&#039;t allowed to perform a join to the same table twice to retrieve the value of the suburb name.<BR><BR>I am wondering what would be the best way to handle this<BR><BR>Thanks in advance<BR><BR>Regards<BR><BR>Richard

  2. #2
    David Moran Guest

    Default RE: 2 Suburb_id's in same table...

    Use an alias to distinguish the 2 joins eg:<BR><BR>SELECT suburb_t.name, suburb_t_1.name<BR>FROM suburb_t AS suburb_t_1 INNER JOIN (suburb_t INNER JOIN address ON suburb_t.suburb_id = address.suburb_id_1) ON suburb_t_1.suburb_id = address.suburb_id_2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts