inner join between 3 tables

后端 未结 3 1583
悲&欢浪女
悲&欢浪女 2021-01-29 11:53

i have these table in database:

country:

id      country
------------------
1       USA
2       Brazil

and segment table:

id           


        
相关标签:
3条回答
  • 2021-01-29 12:35
    SELECT * 
    FROM third_table t
    INNER JOIN country c ON t.country_id = c.country_id
    INNER JOIN segment s ON t.segment_id = s.segment_id
    
    0 讨论(0)
  • 2021-01-29 12:46

    you just try this

    $sql = select * from third_table 
           inner join country on third_table.country_id = country.id
           inner join segment on third_table.segment_id = segment.id
    $res = mysql_query($sql);
    
       'or'
    
    
       select * from TableA A 
       inner join TableB B on A.Column=B.Column 
       inner join TableC C on A.Column=C.Column

    0 讨论(0)
  • 2021-01-29 12:46

    try this query.. this will help you to create list

    select countrysegments.id as countrysegmentsID, country.country as countryName,
    segment.country as segmentName
    from countrysegments 
           inner join country on countrysegments.country_id  = country.id
           inner join segment on countrysegments.segment_id = segment.id
    
    0 讨论(0)
提交回复
热议问题