title: How can I update the field if ID changes MYSQL
body: <p>Every month I receive files which I stacked them in the database with file date we received.</p>
  <p>If the same ID has different memberid in the next month, then I should close that member in current month</p>
  <p>For example below if my table</p>
  <pre><code>ID         membername     memberid      filedate     enddate
  12345      Alpha          5678          2020-01-01
  12345      Alpha          5678          2020-04-01
  12345      Beta           9569          2020-05-01
  12345      Gamma          8765          2020-08-01
  </code></pre>
  <p>As you see ID 12345 has same memeberid until 2020-05-01 then the memberid changed to 9569, now I need to update the enddate with one day before the most recent date (In this case it should be 2020-04-30).</p>
  <pre><code>ID         membername     memberid      filedate     enddate
  12345      Alpha          5678          2020-01-01   2020-04-30
  12345      Beta           9569          2020-05-01   2020-07-31
  12345      Gamma          8765          2020-08-01   2999-12-31
  </code></pre>