سؤال

There are two columns in a table Trades, Id1 and Id2, and I want to get a report that links to the persons name in Name table.

I want to use:

    INNER JOIN Name
ON Trades.Trades_Id1 = Name.NameId
    INNER JOIN Name
    ON Trades.Trades_Id2 = Name.NameId

I know I have to use correlation names, but even with the examples in other posts, I can't figure it out.

هل كانت مفيدة؟

المحلول

You will need to use different alias names for your user table... Something like

select
      T.Trades_ID1,
      N1.Name as Trade1Name,
      T.Trades_ID2,
      N2.Name as Trade2Name
   from
      Trades T
         JOIN NAME N1 on T.Trades_ID1 = N1.NameID
         JOIN NAME N2 on T.Trades_ID2 = N2.NameID
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top