title: Using Group by and select all in a SQL Query
body: <p>I have <strong>employee_data</strong> table with following fields,</p>
  
  <ul>
  <li>id - Integer (Auto Increment)</li>
  <li>first_name - text</li>
  <li>last_name -text</li>
  </ul>
  
  <p>And I have <strong>title table</strong> with following fields,</p>
  
  <ul>
  <li>id - Integer (Auto Increment)</li>
  <li>title_name - text</li>
  </ul>
  
  <p>And I have <strong>employee_title</strong> table with following fields,</p>
  
  <ul>
  <li>id - Integer (Auto Increment)</li>
  <li>title_id - integer (id of title table -fkey)</li>
  <li>period_to - date</li>
  </ul>
  
  <p>I want to get the max <code>period_to</code> with all 3 table data according to each employee by joining the 3 tables.
  But i cannot retrieve all data because of a error showing.
  error : <code>column "jt.code" must appear in the GROUP BY clause or be used in an aggregate function</code></p>
  
  <h2>my sql</h2>
  
  <pre><code>SELECT ed.*, max(et.period_to) FROM employee_data ed 
  JOIN employee_title et ON et.employee_id=ed.id 
  JOIN title jt ON jt.id=et.title_id
  WHERE et.deleted = 0 
  GROUP BY ed.id;
  </code></pre>
  
  <p>I want to select all data. Please help me on this.</p>