title: MySQL Append To Year Values
body: <p>I have following format in mysql:</p>
  
  <pre><code>{"2017": {"1": {"payed": 0, "charge": 0}}}
  </code></pre>
  
  <p>Using this format i make earlier SQL Query and that works very nice (read/update payed and charge values), but i have problem when i need to append to it "2018" year so that i need to get this:</p>
  
  <pre><code>{"2017": {"1": {"payed": 0, "charge": 0}}, "2018": {"1": {"payed": 0, "charge": 0}}}
  </code></pre>
  
  <p>I try using this code to add "2018" year:</p>
  
  <pre><code>UPDATE calculation 
  SET payment = JSON_ARRAY_APPEND(payment, '$', CAST('{"2018": {"1": {"payed": 0,"charge": 0}}}' as JSON));
  </code></pre>
  
  <p>And get THIS:</p>
  
  <pre><code>[{"2017": {"1": {"payed": 0, "charge": 0}}}, {"2018": {"1": {"payed": 0, "charge": 0}}}]
  </code></pre>
  
  <p>And my previus SQL Query does not work because thees needs to be:</p>
  
  <pre><code>{"2017": {"1": {"payed": 0, "charge": 0}}, "2018": {"1": {"payed": 0, "charge": 0}}}
  </code></pre>
  
  <p>How can i successfully append to get this format that i need? Rewriting previus SQL Query for this is alot of work and all is connected..so i need to append and get this format...thanks.</p>