title: MySQL Select first N rows from table with rows related to another one
body: <p>I have a repayments table which has 16 rows for each loan that the repayments belong.</p>
  
  <pre><code>Repayments
  loanid  repid  amnt
  --------------------
  a1      r1     1,100
  a1      r2     1,100
  |       |      |
  a1      r16    1,105
  b2      s1     2,500
  b2      s2     2,500
  |       |      |
  b2      s16    2,510
  |       |      |
  
  Loans
  loanid  othercolumns...
  -----------------------
  a1
  b2
  |
  blahid
  |
  </code></pre>
  
  <p>LoanIds are some string.
  RepaymentIds too</p>
  
  <p>I'm looking for a query which gives me the first 15 rows from each repayments for every loan.</p>
  
  <pre><code>loanid  repid  amnt
  a1      r1     1,100
  a1      r2     1,100
  |       |      |
  a1      r15    1,105
  b2      s1     2,500
  b2      s2     2,500
  |       |      |
  b2      s15    2,510
  |       |      |
  </code></pre>
  
  <p>Is this possible with SQL? and if so, how?</p>