1

I have this json array data and the data can be up to n numbers

{
  0: {
    loan_id: 348,
    period_start: '2019-12-30',
    period_end: '2020-01-14',
    month: 1,
    fr_principal: null,
    fr_interest: null,
    br_principal: 50.00,
    br_interest: 50.00,
  },
  1: {
    loan_id: 348,
    period_start: '2020-01-15',
    period_end: '2020-01-29',
    month: 1,
    fr_principal: null,
    fr_interest: null,
    br_principal: 50.00,
    br_interest: 50.00,
  }
}

I want this data to be store in a table name loan_schedule . Below is the column field

INSERT INTO loan_schedule
(loan_id,period_start,period_end,month,fr_principal,fr_interest,br_principal,br_interest)

Let say the json array data is 0 and 1, so it will insert 2 row in table loan_schedule, if the data is 0 to 5, so it will insert 6 rows

How to do this ?

*** I'm using mysql server 5.7

0 Answers0