title: MySQL: A help needed in Query using 4 tables
body: <p>There are these four tables:</p>
  
  <pre><code>posts
  posts_replies
  likes
  myfavorite
  </code></pre>
  
  <p>I am using the following query to return me data from first 3 tables. But the 4th table (myfavorite), i want it to be also included into it and load the post that user has selected as Favorite.</p>
  
  <pre><code>SELECT  posts.title, 
      posts.num, 
      posts.status, 
      posts.category, 
      posts.content, 
      posts.member_num, 
      COUNT( posts_replies.post_num ) AS count, 
      COUNT( likes.comment_num ) AS likes_count
  FROM    posts
      LEFT JOIN posts_replies 
          ON ( posts_replies.post_num = posts.num )
      LEFT JOIN likes 
          ON ( likes.comment_num = posts_replies.num )
  WHERE   posts.member_num = '84'
  GROUP   BY posts.num 
  ORDER   BY posts.num 
  </code></pre>
  
  <p>myfavorite table has following fields:</p>
  
  <pre><code>id (primary key)
  member_num 
  recordNum 
  table ('posts' OR 'members')
  </code></pre>
  
  <p>I tried adding the following left join into the above query to pull the records from myfavorite table too, but its not working:</p>
  
  <pre><code>LEFT JOIN myfavorite 
  ON ( myfavorite.recordNum = posts.num )
  </code></pre>
  
  <p>I am confused with this query, any advices on this?</p>
  
  <p>Thank you</p>
  
  <p><em><strong></em> EDIT **</strong></p>
  
  <p>Here are the tables with sample data from <code>posts</code> and <code>myfavorite</code> tables:</p>
  
  <p>table: <code>myfavorite</code></p>
  
  <pre><code>id  |   member_num  |   recordNum   |   table   
  72  |   84          |   74          |   blyrbs
  </code></pre>
  
  <p>table: <code>posts</code></p>
  
  <pre><code>title       |   num |   status  |   category    |   content                 |   member_num
  Testing Post|   117 |       1   |   0           |   testing...              |   84
  My Fav Post |   107 |       1   |   0           |   this is the fav post... |   22
  </code></pre>