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 6174771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:48:26+00:00 2026-05-23T23:48:26+00:00

I have 3 tables as shown in the diagram: The test data in each

  • 0

I have 3 tables as shown in the diagram:
Table Design

The test data in each of these tables is as given below:

ACCOUNT_GROUP

     GroupID    Name
     101    Bank Accounts
     105    Cash-in-hand
     113    Indirect Expenses
     120    Purchase Accounts
     122    Sales Accounts
     125    Sundry Creditors

ACCOUNT_MASTER

AccID   Name          GroupID
1001    RBS A/C 23456   101
1002    HSBC A/C 123456 101
1003    CASH A/C        105
1004    DISCOUNT        113
1005    CASH SALES      122
1006    CASH PURCHASE   120
1007    JOHNSON         125

ACCOUNT_TXNS

TxnID   TxnDate  FromAccID  ToAccID Amt CrDr
1   20-Jul-2011 1002    1003    250000  C
2   20-Jul-2011 1001    1002    985241  C
3   20-Jul-2011 1005    1003    65451   C
4   20-Jul-2011 1006    1003    412874  D
5   20-Jul-2011 1007    1003    521400  C
6   20-Jul-2011 1003    1007    200     D

I want to get the account names of both FromAccID and ToAccID and their group names in a single query like this:

TxnID   TxnDate FromAcc         FromAccGroup      ToAcc            ToAccountGroup    Amt    CrDr
1   20-Jul-2011 HSBC A/C 123456 Bank Accounts     CASH A/C          Cash-in-hand     250000 C
2   20-Jul-2011 RBS A/C 23456   Bank Accounts     HSBC A/C 123456   Bank Accounts    985241 C
3   20-Jul-2011 CASH SALES      Sales Accounts    CASH A/C          Cash-in-hand     65451  C
4   20-Jul-2011 CASH PURCHASE   Purchase Accounts CASH A/C          Cash-in-hand     412874 D
5   20-Jul-2011 JOHNSON         Sundry Creditors  CASH A/C          Cash-in-hand     521400 C
6   20-Jul-2011 CASH A/C        Cash-in-hand      JOHNSON           Sundry Creditors 200    D

Kindly help me to achieve this.

  • 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-23T23:48:27+00:00Added an answer on May 23, 2026 at 11:48 pm

    You can use the same table more than once in a single query, just use aliases.

    Something like

    SELECT  *
    FROM    ACCOUNT_TXNS txns INNER JOIN
            ACCOUNT_MASTER fromAcc  ON  txns.FromAccID = fromAcc.AccID INNER JOIN
            ACCOUNT_GROUP fromAccGrp    ON  fromAcc.GroupID = fromAccGrp.GroupID INNER JOIN
            ACCOUNT_MASTER toAcc    ON  txns.ToAccID = toAcc.AccID INNER JOIN
            ACCOUNT_GROUP toAccGrp  ON  toAcc.GroupID = toAccGrp.GroupID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two MySql tables as shown below with the data shown: CREATE TABLE
I have two tables as shown in the following diagram : as you saw
I have three tables as shown below Emp ---- empID int empName deptID empDetails
I have three simple tables as shown below: +----+-------------+ +----+-----------+ +----+---------------+ | artists |
I have two tables as shown below The master Table ID keyword_tags ----------- ---------------------------------------------
I have two tables as shown below: **tblComments** Commentid addeddate Postid **tblPosts** Postid AddedBy
I have 2 tables as follows (sample data shown): TableName: A ID Type 1
I have three tables with a one to many relationship as shown below. What
I have two tables as shown below EmpMaster empid firstName lastName lstatus 1 Mark
I am new to Oracle 10g. I have couple of tables as shown below:

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.