Q:

Select n items starting with each alphabet from a-z in MySQL

I have tried asking this question previously but moderators closed the question citing it as not clear. Hope this time I make it clear. 
I've a services table with up to 1000 services. The table has id & service_title column. So, I basically want to get 10 services each for each alphabet starting from A to Z. If there are fewer than 10 items starting with any particular alphabet than I want to get them all. Also I want them in alphabetical order if possible.
Here's my services table.

So my output table should look something like the one displayed below. For the sake of simplicity I've shown 2 services starting with each alphabet from A to J.

<table border="1">
 <caption>Services</caption>
 <thead>
  <tr>
   <th>id</th>
   <th>name</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>1</td>
   <td>Auditing</td>
  </tr>
  <tr>
   <td>2</td>
   <td>Accounting</td>
  </tr>
  <tr>
   <td>3</td>
   <td>Brick laying</td>
  </tr>
  <tr>
   <td>4</td>
   <td>Builders</td>
  </tr>
  <tr>
   <td>5</td>
   <td>Carpet Cleaning</td>
  </tr>
  <tr>
   <td>6</td>
   <td>Carpenters</td>
  </tr>
  <tr>
   <td>7</td>
   <td>Demolition</td>
  </tr>
  <tr>
   <td>8</td>
   <td>Dog Walking</td>
  </tr>
  <tr>
   <td>9</td>
   <td>Electrician</td>
  </tr>
  <tr>
   <td>10</td>
   <td>Equipment Hire</td>
  </tr>
  <tr>
   <td>11</td>
   <td>Fencing & Gates</td>
  </tr>
  <tr>
   <td>12</td>
   <td>Fright Services</td>
  </tr>
  <tr>
   <td>13</td>
   <td>Gardeners</td>
  </tr>
  <tr>
   <td>14</td>
   <td>Gate keepers</td>
  </tr>
  <tr>
   <td>15</td>
   <td>Handyman</td>
  </tr>
  <tr>
   <td>16</td>
   <td>Health service</td>
  </tr>
  <tr>
   <td>17</td>
   <td>Interview Trainer</td>
  </tr>
  <tr>
   <td>18</td>
   <td>Iterpersonal Relationship Coach</td>
  </tr>
  <tr>
   <td>19</td>
   <td>Joinery Experts</td>
  </tr>
  <tr>
   <td>20</td>
   <td>Jacket Maker</td>
  </tr>
 </tbody>
</table>

Here's the code I've come up with till now
SELECT *
    FROM (
    SELECT id, service_title,
    @count := IF(@value = service_title, @count + 1, 1) AS count
    FROM services, (SELECT @count := 1, @value := NULL) a
    WHERE services.service_title REGEXP  '^[A-z]+$'
    ) a
WHERE a.count <= 10
Order by service_title

I've listed some services in my sample output table which are not listed in the sample items on the table image, please do not raise that as as issue as I can't display all items on the sample table image.

A:

You may try below query with minor updates from your query -
SELECT *
FROM (SELECT id,
             @count := IF(LEFT(@value, 1) = LEFT(service_title, 1), @count + 1, 1) AS cnt,
             @value := service_title service_title
    FROM services, (SELECT @count := 0, @value := 0) vars
    WHERE services.service_title REGEXP  '^[A-z]+'
    ORDER BY service_title, id
    ) a
WHERE a.cnt <= 10
Order by service_title, id

Demo.

