title: How to merge multiple rows in MySQL?
body: <p>I ran into some problems while structuring my database, and I will ask two questions.</p>
  
  <p>First question: below table needs to be merged by the same IDs</p>
  
  <pre><code> ╔═════╦═══════╦═════╦═══════╗
   ║ id* ║ name  ║ age ║ grade ║
   ╠═════╬═══════╬═════╬═══════╣
   ║  0  ║ John  ║     ║       ║
   ║  0  ║       ║ 11  ║       ║
   ║  0  ║       ║     ║   6   ║
   ║  1  ║ Dave  ║     ║       ║
   ║  1  ║       ║ 12  ║       ║
   ║  1  ║       ║     ║   7   ║
   ╚═════╩═══════╩═════╩═══════╝
  </code></pre>
  
  <p>so it should look like this;</p>
  
  <pre><code> ╔═════╦═══════╦═════╦═══════╗
   ║ id* ║ name  ║ age ║ grade ║
   ╠═════╬═══════╬═════╬═══════╣
   ║  0  ║ John  ║ 11  ║   6   ║
   ║  0  ║ Dave  ║ 12  ║   7   ║
   ╚═════╩═══════╩═════╩═══════╝
  </code></pre>
  
  <p>NOTE: id* is not AUTO_INCREMENT</p>
  
  <hr>
  
  <p>Second question: You probably think that the former database structure is poor. The good thing is, I haven't created the database yet and I have been looking for a solution to add data to an existing row without removing old information, but if there is no old information, it would create a new row. Thanks in advance.</p>
  
  <h2>Second question explained</h2>
  
  <p>Virgin table</p>
  
  <pre><code> ╔═════╦═══════╦═════╦═══════╗
   ║ id* ║ name  ║ age ║ grade ║
   ╠═════╬═══════╬═════╬═══════╣
   ║     ║       ║     ║       ║
   ╚═════╩═══════╩═════╩═══════╝
  </code></pre>
  
  <p><em>some SQL statement</em></p>
  
  <pre><code> ╔═════╦═══════╦═════╦═══════╗
   ║ id* ║ name  ║ age ║ grade ║
   ╠═════╬═══════╬═════╬═══════╣
   ║  0  ║ John  ║     ║       ║
   ╚═════╩═══════╩═════╩═══════╝
  </code></pre>
  
  <p><em>the same SQL statement with different parameters</em></p>
  
  <pre><code> ╔═════╦═══════╦═════╦═══════╗
   ║ id* ║ name  ║ age ║ grade ║
   ╠═════╬═══════╬═════╬═══════╣
   ║  0  ║ John  ║     ║       ║
   ║  1  ║ Dave  ║     ║       ║
   ╚═════╩═══════╩═════╩═══════╝
  </code></pre>
  
  <p><em>another SQL statement</em></p>
  
  <pre><code> ╔═════╦═══════╦═════╦═══════╗
   ║ id* ║ name  ║ age ║ grade ║
   ╠═════╬═══════╬═════╬═══════╣
   ║  0  ║ John  ║     ║       ║
   ║  1  ║ Dave  ║ 12  ║       ║
   ╚═════╩═══════╩═════╩═══════╝
  </code></pre>
  
  <p><em>another SQL statement</em></p>
  
  <pre><code> ╔═════╦═══════╦═════╦═══════╗
   ║ id* ║ name  ║ age ║ grade ║
   ╠═════╬═══════╬═════╬═══════╣
   ║  0  ║ John  ║     ║   6   ║
   ║  1  ║ Dave  ║ 12  ║       ║
   ╚═════╩═══════╩═════╩═══════╝
  </code></pre>
  
  <p>... and so on.</p>