Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 596545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:11:00+00:00 2026-05-13T16:11:00+00:00

I have a currency(Rec_ID, currency) table which is having M-M relationship with it self

  • 0

I have a currency(Rec_ID, currency) table which is having M-M relationship with it self it results in CurrencyExchangeRate table (Rec_ID, Currency_FK1 AS ‘FROM’, Currency_FK2 AS ‘TO, Exchange_Rate)

Now I need a query to do all combination of currency rec_id (repetition is not allowed),
along with the exchange rate or null. if there is 3 records in Currency then I the query should return 6 rows.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:11:00+00:00Added an answer on May 13, 2026 at 4:11 pm
    SELECT
       CCY1, CCY2, CER.Exchange_Rate
    FROM
        ( 
        SELECT
            c1.rec_id AS rec_id1, c1.currency AS CCY1,
            c2.rec_id AS rec_id2, c2.currency AS CCY2
        FROM
            currency c1
            CROSS JOIN --all combinations...
            currency c2
        WHERE
            c1.rec_id <> c2rec_id -- ...removes same pairs
        ) foo
        LEFT JOIN -- ...get matching FX pairs
        CurrencyExchangeRate CER ON foo.rec_id1 = cer.[from] AND foo.rec_id2 = cer.[to]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MySQL and have an articles table which has 2 columns: currency
I have been told the following is insecure: cursor.execute(SELECT currency FROM exchange_rates WHERE date='%s'%(self.date))
I have a currency converter application for iphone which uses web service. The web
I have a GWT project in which I need to manually specify currency, number
I have a Currency class which I persist to my database using NHibernate. Currency
I have get currency code (Eg: USD, EUR, INR) from webservice response. I need
I have an $.ajax() request that queries currency exchange rate information from another web
I have a table with the following columns: reportDate DATETIME and losses CURRENCY and
I have the following query: SELECT rate AS theRate, currency AS curr FROM _currency
I have a currency calculator that requires buttons to convert to/from currencies. I'd like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.