title: Get only one record from child table
body: <p>Hi I am using the following query to select only one file from child table that has a matching id with the parent table but its giving error. please help</p>
  
  <pre><code>    $query = $this -&gt; db -&gt; query("select post.id AS PostID, post.*, 
  post_files.* from post LEFT JOIN post_files ON post.category_id='1' AND 
  post.id=(SELECT * FROM post_files WHERE post.id=post_files.post_id LIMIT 1)");
  </code></pre>
  
  <p>post is the table where main information of posts will be saved and all the files likes images will be saved in post_files table. So i want to get only one file from post_files.</p>