For Example, Ihave 1 table table_source :
ID | Price | Date |
---|---|---|
Data 1 | Price 1 | 1Nov2022 |
Data 2 | Price 2 | 9Nov2022 |
I want to insert into 2 table ,
Table_Header:
Number_trans | Id | Date |
---|---|---|
1 | Data 1 | 1Nov2022 |
2 | Data 2 | 9Nov2022 |
And Table_Detail
Number_trans | COA | Debit | Credit |
---|---|---|---|
1 | aaaa | xx | 0 |
1 | bbbb | 0 | xx |
1 | cccc | yy | 0 |
1 | dddd | 0 | yy |
2 | aaaa | zz | 0 |
2 | bbbb | 0 | zz |
2 | cccc | 0 | |
2 | dddd | 0 |
don't worry about xx, yy, zz and qq --it's count with some formulas from price and other thing's.. For example : xx is price 1, yy is price 1 x 11%, zz is price 2, qq is price 2 x 11%.
How can I do insert into 1 row (in table_header) and 4 rows (in table_detail) from 1 single row in table_source? Can I do it with single sql statement?
insert sql into multi tables with one statement