title: Count unique integer value between multiple overlapping ranges saved in mysql table + PHP
body: <p>We have a situation to get unique count between saved range of mysql table. lets say, I have data saved in table like below:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">sr_no</th>
  <th style="text-align: left;">start_sr_no</th>
  <th style="text-align: center;">end_sr_number</th>
  <th style="text-align: right;">total_count</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">1</td>
  <td style="text-align: left;">1</td>
  <td style="text-align: center;">10</td>
  <td style="text-align: right;">10</td>
  </tr>
  <tr>
  <td style="text-align: left;">2</td>
  <td style="text-align: left;">5</td>
  <td style="text-align: center;">15</td>
  <td style="text-align: right;">11</td>
  </tr>
  <tr>
  <td style="text-align: left;">3</td>
  <td style="text-align: left;">27</td>
  <td style="text-align: center;">35</td>
  <td style="text-align: right;">9</td>
  </tr>
  <tr>
  <td style="text-align: left;">4</td>
  <td style="text-align: left;">11</td>
  <td style="text-align: center;">21</td>
  <td style="text-align: right;">11</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>now see in above records, row sr_no 2 is overlapping the row sr_no 1 and row sr_no 4 so the unique total_count of all 3 range should be: 21 instead of 10+11+11 = 32 and all range total count should be:30 instead of 10+11+9+11:41</p>