• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

joining tables sql and php

table 1    (this is the principal table)

name      location       district
LG                1                   3
GT                34                 20
......

table 2

district     name_district    region
3                     ftt_as              1
20                   trt_we             7
........

table 3

region      name_region
1                   reg1
7                   reg3

i need a result table from the SELECT stamens like this

name_region   name_district      name     location
reg1                          ftt_as                 LG           1
reg3                          trt_we                GT           34
and so on.....

Any idea? I know how to do the name_district with a JOIN, but how to make the region part that is related between the table 2 and table 3 and not any in the table 1? my problem is that the region field doesn't exist in the table 1 that is the principal table for the select statement, any idea?
0
joyacv2
Asked:
joyacv2
1 Solution
 
GaryCommented:
SELECT * FROM table1
INNER JOIN table2 on table2.district=table1.district
INNER JOIN table3 on table3.region=table2.region

Open in new window

0
 
joyacv2Author Commented:
works perfect!!!!!!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now