MYSQL

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Join 2 tables using specific fields

    1 answers - 354 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    I have 2 table.
    Zones(Z1Z20) and Radius(R0R4)
    where
    R0 is equivalent to Z1
    R1 " Z5
    R2 " Z9
    R3 " Z13
    R4 " Z17
    How can I make the query to join them in such ways?
    eg:
    select
    A,B,C,D
    from
    Zone
    inner join radius
    on R1 = Z5
    on R2 = Z9
    on R3 = Z13
    on R4 = Z17
    or do I have to use a subquery?
  • No.1 | | 748 bytes | |

    Mun Heng wrote:
    I have 2 table.
    Zones(Z1Z20) and Radius(R0R4)
    where
    R0 is equivalent to Z1
    R1 " Z5
    R2 " Z9
    R3 " Z13
    R4 " Z17

    How can I make the query to join them in such ways?

    eg:
    select
    A,B,C,D
    from
    Zone
    inner join radius
    on R1 = Z5
    on R2 = Z9
    on R3 = Z13
    on R4 = Z17

    or do I have to use a subquery?

    How about:
    select A,B,C,D from Zone
    left join radius
    on R1 = Z5
    and R2 = Z9
    and R3 = Z13
    and R4 = Z17

    select A,B,C,D from Zone
    left join radius
    on R1 = Z5
    or R2 = Z9
    or R3 = Z13
    or R4 = Z17

    It's not clear what the relationship is between the tables so I don't
    know which of the two is what you want.

Re: Join 2 tables using specific fields


max 4000 letters.
Your nickname that display:
In order to stop the spam: 3 + 2 =
QUESTION ON "MYSQL"

EMSDN.COM