title: MySQL Multiple Left Join Limit
body: <p>How would I impose a left join limit on query with multiple left joins that depend on one another? See comment below on the LIMIT:</p>
  
  <pre><code>SELECT 
      a.*,GROUP_CONCAT(c.body SEPARATOR ' ') AS bodies
  FROM a   
      LEFT JOIN b ON b.id_a=a.id    
      LEFT JOIN c ON c.id=b.id_c LIMIT 5 # LIMIT 5 Here Does Not Work 
  WHERE ...
  </code></pre>
  
  <p>Sample data set...</p>
  
  <pre><code>DROP TABLE IF EXISTS `a`;
  CREATE TABLE `a` (  
    `id` int(11) NOT NULL
  );
  
  -- Contains relationship between a and c
  DROP TABLE IF EXISTS `b`;
  CREATE TABLE `b` (
    `id_a` int(11) NOT NULL,
    `id_c` int(11) NOT NULL
  );
  
  -- Contains body contents
  DROP TABLE IF EXISTS `c`;
  CREATE TABLE `c` (
    `id` int(11) NOT NULL,
    `body` varchar(2000) NOT NULL
  );
  
  
  -- ----------------------------
  -- Sample Records
  -- ----------------------------
  INSERT INTO `a` VALUES ('1');
  
  INSERT INTO `b` VALUES 
  ('1','1'), ('1','2'), ('1','3'),
  ('1','4'), ('1','5'), ('1','6'),
  ('1','7'), ('1','8'), ('1','9'), 
  ('1','10');
  
  INSERT INTO `c` VALUES
  ('1','aa'),('2','bb'), ('3','cc'),
  ('4','dd'), ('5','ee'), ('6','ff'),
  ('7','gg'), ('8','hh'), ('9','ii'),
  ('10','jj');
  </code></pre>
  
  <p>... and SQLFiddle at <a href="http://sqlfiddle.com/#!9/c1822/12" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/c1822/12</a>  </p>
  
  <p>Also here is a subquery rewrite that I tried but doesn't work because the outer table is not accessible from the nested subquery and fails with "unknown column a.id in where clause": <a href="http://sqlfiddle.com/#!9/c1822/3" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/c1822/3</a> </p>
  
  <p>Also here is a subquery find_in_set rewrite <a href="http://sqlfiddle.com/#!9/2d43bb/1" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/2d43bb/1</a> which works but is too slow with large data sets.</p>