Sybase查询多个指向单个主键的外键

时间:2013-06-21 11:38:27

标签: sybase

我有2个表货币和成对的以下字段,

货币

  • Currencies_ShortName

  • Currencies_Id(主键)

  • Pairs_ShortName

  • Currencies_Id_1 Reference(Currencies)Currencies_Id

  • Currencies_Id_2 Reference(Currencies)Currencies_Id

我想显示Pairs_ShortName,Currencies_Id_1& Currencies_Id_2 with Currencies_ShortName。

我试过了 Select a.Pairs_ShortName, a.Currencies_Id_1, a.Currencies_Id_2, b.Currencies_ShortName from Pairs a, Currencies b where a.Currencies_Id_1 = .Currencies_Id

但它只显示Pairs_ShortName,Currencies_Id_1,Currencies_ShortName。

我想显示Pairs_ShortName,Currencies_Id_1,Currencies_ShortName,Currencies_Id_2,Currencies_ShortName

1 个答案:

答案 0 :(得分:0)

检查以下查询,

选择
 p.Pairs_ShortName,p.Currencies_Id_1,c1.Currencies_ShortName1,p.Currencies_Id_2,c .Currencies_ShortName2
从 对p,货币c1,货币c2
其中p.Currencies_Id_1 = c1.Currencies_Id
和p.Currencies_Id_2 = c2.Currencies_Id

谢谢..