title: Mysql limit in each subquery
body: <p>I have a table with categories</p>
  
  <pre><code>Categories
  id | title | visible
  1  |  one  |    1
  2  |  two  |  null
  3  | three |    1
  </code></pre>
  
  <p>a table with photos from the categories above</p>
  
  <pre><code>Photos
  id | category_id |     title      | visible
  1  |      1      |  photo.one     |    1
  2  |      1      |  photo.two     |  null
  3  |      1      |  photo.three   |    1
  4  |      1      |  photo.four    |    1
  5  |      2      |  photo.five    |  null
  6  |      2      |  photo.six     |    1
  7  |      3      |  photo.seven   |    1
  8  |      3      |  photo.eight   |    1
  9  |      3      |  photo.nine    |    1
  </code></pre>
  
  <p>I need to take only 2 photos with photos.visible = 1 from every category with category.visible = 1.</p>
  
  <p>I tried with limit but i can limit only all records, not per category. </p>
  
  <p>The result has to be</p>
  
  <pre><code>Result
  id | category_id |     title      | visible | category_title
  1  |      1      |  photo.one     |    1    |      one
  2  |      1      |  photo.three   |    1    |      one
  3  |      3      |  photo.seven   |    1    |     three
  4  |      3      |  photo.eight   |    1    |     three
  </code></pre>
  
  <p>Any help please?</p>