title: Sub Query counting character strings in MySQL
body: <pre><code>LEFT JOIN
  (
      SELECT user_id, review, COUNT(user_id) totalCount
      FROM reviews
      GROUP BY user_id
  ) b ON b.user_id= b.user_id 
  </code></pre>
  
  <p>I am trying to fit <code>WHERE LENGTH(review) &gt; 100</code> in this somewhere but every I put it, it gives me problems.</p>
  
  <p>The sub-query above counts all total reviews by <code>user_id</code>.  I simply want to add one more qualification.  Only count reviews greater than 100 length.</p>
  
  <p>On a side note, I've seen the function <code>CHAR_LENGTH</code> -- not sure if that i what I need either.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is complete query working perfectly as expected for my needs:</p>
  
  <pre><code>    static public $top_users = "
              SELECT  u.username, u.score,
              (COALESCE(a.totalCount, 0) * 4) +
              (COALESCE(b.totalCount, 0) * 5) +
              (COALESCE(c.totalCount, 0) * 1)  +
              (COALESCE(d.totalCount, 0) * 2)  +
              (COALESCE(u.friend_points, 0)) AS totalScore
              FROM users u 
              LEFT JOIN
                  (
                      SELECT user_id, COUNT(user_id) totalCount
                      FROM items 
                      GROUP BY user_id
                  ) a ON a.user_id= u.user_id
              LEFT JOIN
                  (
                      SELECT user_id, COUNT(user_id) totalCount
                      FROM reviews
                      GROUP BY user_id
                  ) b ON b.user_id= u.user_id
              LEFT JOIN
                  (
                      SELECT user_id, COUNT(user_id) totalCount
                      FROM ratings
                      GROUP BY user_id
                  ) c ON c.user_id = u.user_id
               LEFT JOIN
                  (
                      SELECT user_id, COUNT(user_id) totalCount
                      FROM comments
                      GROUP BY user_id
                  ) d ON d.user_id = u.user_id
  
                  ORDER BY totalScore DESC LIMIT 25;";
  </code></pre>