Saturday 15 August 2015

Sybase query for multiple foreign key pointing to a single primary key -


I have 2 tables containing currencies and pairs, with the following fields,

currencies

  • >

    pairs

    • Pairs_ShortName

    • currencies_ID_1 reference (currencies) currency_ID

    • currencies_ID_2 reference (currencies) currencies_ID

      I used Pairs_ShortName, currencies_ID_1 & amp; Currencies with currency_order_1_sortname

      I tried - choose a.Pairs_ShortName, a.Currencies_Id_1, a.Currencies_Id_2, b.Currencies_ShortName from pair, currencies b where a.Currencies_Id_1 = .Currency_Id

      But it only shows Pairs_ShortName, Currency_Id_1, Currency_ShortName

      I can add Pairs_ShortName, Currency_ID_1, Currency_sortname, Currency_ID_2, Currency_sortname

      Click the question below, select

      - p.Pairs_ShortName, p.Currencies_Id_1, c1.Currencies_ShortName1, p.Curculans_Id_2, c.Currencies_ShortName2
      Pairs from P, currencies C1, currencies C2
      where p .currencies_Id_1 = c1.Currencies_Id
      and p.Currencies_Id_2 = c2.Currencies_Id

      thanks ..

No comments:

Post a Comment