sql statement

  • IDID_NAMECHILD_IDCHILD_NAME

    0General Ledger1Assets

    0General Ledger2Liabilities

    0General Ledger3Equity

    0General Ledger4Revenues

    0General Ledger5Cost of Sales

    0General Ledger6Expenses

    53Fixed Assets22ZXX

    53Fixed Assets23fsdfdf

    53Fixed Assets24sdfs

    1Assets51Current Assets

    1Assets53Fixed Assets

    1Assets54Other Assets

    2Liabilities55Current Liabilities

    2Liabilities56Long-Term Liabilities

    4Revenues57Sales

    4Revenues58Other Income

    55Current Liabilities59Account Payable

    55Current Liabilities60Loans and Advances

    53Fixed Assets61Furniture and Fixers

    5Cost of Sales62Purchases (Credit)

    51Current Assets63Cash in Hand

    51Current Assets64Accounts Receivables

    51Current Assets65Other Current Assets

    51Current Assets66Other Receivable

    5Cost of Sales67Local Purchase(Cash)

    6Expenses68Staff Salaries

    6Expenses69ABC

    6Expenses70XYZ

    6Expenses71Personal and Administrative Exp

    5Cost of Sales72Fright

    5Cost of Sales73Clearing Charges

    5Cost of Sales74Customs Duty

    5Cost of Sales75Carrige Inwords

    53Fixed Assets76Office Equipments

    53Fixed Assets77Loose Tools

    51Current Assets78Cash at Bank

    51Current Assets79Stock

    3Equity80Capital-Owners Equity

    51Current Assets81Pre Paid Expenses

    51Current Assets82Short Time Deposit

    64Accounts Receivables83SAVOLA GROUPS

    53Fixed Assets84Motor Vehicles

  • The answer depends on how you want the data formatted. Here is one way:

    Select

    A.id,

    A.id_name,

    A.child_id,

    A.child_name,

    B.id,

    B.id_name,

    B.child_id,

    B.child_name

    From

    table as A Left Join

    table as B On

    A.child_id = B.id

    Where

    A.id = ?

    And here is another:

    Select

    A.id,

    A.id_name,

    A.child_id,

    A.child_name

    From

    table as A

    Where

    A.id = ?

    Union -- or Union ALL if you don't mind duplicates

    Select

    B.id,

    B.id_name,

    B.child_id,

    B.child_name

    From

    table as A Join

    table as B On

    A.child_id = B.id

    Where

    A.id = ?

  • Please don't use polls to ask questions.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply