Child records under the parent record in SQLite I have two tables for Billing, one Bill_Master and other is Bill_Detail. The records in both tables are as follows...

**BILL_MASTER**
id    party    bill_amount
1      abc      500
2      def      600

**BILL_DETAILS**
mstr_id    sr_no    perticular    amount
 1          1        lunch box     100
 1          2        water bag     400
 2          1        pencil boxes  300
 2          2        a4 papers     100
 2          3        staple pins   200


Now I want to make a result table as per below

**RESULT_TABLE**
mstr_id    party      billamount
 1         abc           500
           lunch box     100
           water bag     400
 2         def           600
           pencil boxes  300
           a4 papers     100
           staple pins   200


How can I do it?
The following query creates these rows:


mstr_id    party      billamount  sort1  sort2
 1         abc           500        1     -1     from bill_master
 2         def           600        2     -1
           lunch box     100        1      1     from bill_details
           water bag     400        1      2
           pencil boxes  300        2      1
           a4 papers     100        2      2
           staple pins   200        2      3


These sort* values cause the rows to be ordered correctly after sorting.

SELECT id AS mstr_id,
       party,
       bill_amount AS billamount,
       id AS sort1,
       -1 AS sort2
FROM BILL_MASTER
UNION_ALL
SELECT NULL,
       perticular,
       amount,
       mstr_id,
       sr_no
FROM BILL_DETAILS
ORDER BY sort1,
         sort2