title: MySQL if statement in GROUP BY
body: <p>I have the following table:</p>
  
  <pre><code>| id | msgType | user | job_id | project_id |
  |+++++++++++++++++++++++++++++++++++++++++++|
  | 1  | 1       | 1    | 1      | 1          |
  | 2  | 1       | 1    | 2      | 1          |
  | 3  | 2       | 1    | 3      | 1          |
  | 4  | 2       | 1    | 4      | 1          |
  | 5  | 1       | 1    | 5      | 2          |
  </code></pre>
  
  <p>This my query:</p>
  
  <pre><code>SELECT msgType ,user, job_id, project_id 
  FROM mail
  GROUP BY msgType,user,project_id,job_id
  </code></pre>
  
  <p>The output whit this query:</p>
  
  <pre><code>| msgType | user | job_id | project_id |
  |++++++++++++++++++++++++++++++++++++++|
  | 1       | 1    | 1      | 1          |
  | 1       | 1    | 2      | 1          |
  | 2       | 1    | 3      | 1          |
  | 2       | 1    | 4      | 1          |
  | 1       | 1    | 5      | 2          |
  </code></pre>
  
  <p>My desired output would be:</p>
  
  <pre><code>| msgType | user | job_id | project_id |
  |++++++++++++++++++++++++++++++++++++++|
  | 1       | 1    | 1      | 1          |
  | 2       | 1    | 3      | 1          |
  | 2       | 1    | 4      | 1          |
  | 1       | 1    | 5      | 2          |
  </code></pre>
  
  <p>So basically <code>if msgType = 1</code> then i want to see 1 row for every user in every different project_id <code>if msgType=2</code> then i want to see every job_id in a "project"</p>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>UPDATE </p>
  
  <p>i created a fiddle for this:</p>
  
  <p><a href="http://sqlfiddle.com/#!2/5708b8/4" rel="nofollow">http://sqlfiddle.com/#!2/5708b8/4</a></p>