?
Solved

joining tables sql and php

Posted on 2014-03-12
2
Medium Priority
?
244 Views
Last Modified: 2014-03-12
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
Comment
Question by:joyacv2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 39923848
SELECT * FROM table1
INNER JOIN table2 on table2.district=table1.district
INNER JOIN table3 on table3.region=table2.region

Open in new window

0
 
LVL 1

Author Closing Comment

by:joyacv2
ID: 39923981
works perfect!!!!!!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question