title: mysql select from different tables with if clause
body: <p><strong>table: user</strong> </p>
  
  <pre><code>| userid | fullname |
  |   1    |  admin   |
  |   2    |  jimmy   |
  |   3    |  anton   |
  |   4    |  steven  |
  </code></pre>
  
  <p><strong>table: maschinen</strong>    </p>
  
  <pre><code>| maschine | maschine-name |
  |    1     |       M1      |
  |    2     |       M2      |
  |    3     |       M3      |
  |    4     |       M4      |
  </code></pre>
  
  <p><strong>table:    vorrichtungen</strong></p>
  
  <pre><code>| id | maschine | vorrichtung | createdby |      datecreated    | updatedby |     dateupdated     |
  | 1  |    1     |    11111    |     1     | 2012-06-23 17:10:25 |     1     | 2012-06-23 18:15:20 |
  | 2  |    1     |    22222    |     1     | 2012-06-25 07:50:49 |     0     | 0000-00-00 00:00:00 |
  | 3  |    2     |    33333    |     2     | 2012-06-27 10:22:29 |     0     | 0000-00-00 00:00:00 |
  | 4  |    3     |    44444    |     2     | 2012-06-28 09:41:27 |     1     | 2012-06-28 12:40:37 |
  | 5  |    4     |    11111    |     3     | 2012-06-29 15:53:47 |     0     | 0000-00-00 00:00:00 |
  | 6  |    4     |    33333    |     4     | 2012-06-29 22:30:02 |     2     | 2012-06-29 22:30:02 |
  </code></pre>
  
  <p><strong>my query looks like this:</strong>       </p>
  
  <pre><code>SELECT
      vorrichtungen.`id`, 
      maschinen.`maschine-name` AS maschine, 
      vorrichtungen.`vorrichtung`, 
      vorrichtungen.`createdby`, 
      user.`fullname` AS creator, 
      vorrichtungen.`datecreated`, 
      vorrichtungen.`updatedby`, 
      vorrichtungen.`dateupdated`
  FROM 
      vorrichtungen,maschinen,user
  WHERE 
      maschinen.`maschine` = vorrichtungen.`maschine` 
  AND 
      vorrichtungen.`createdby` =  user.`userid` 
  </code></pre>
  
  <p><strong>and i recieve this result:</strong></p>
  
  <pre><code>| id | maschine | vorrichtung | createdby | creator |      datecreated    | updatedby |     dateupdated     |
  | 1  |    M1    |    11111    |     1     |  admin  | 2012-06-23 17:10:25 |     1     | 2012-06-23 18:15:20 |
  | 2  |    M1    |    22222    |     1     |  admin  | 2012-06-25 07:50:49 |     0     | 0000-00-00 00:00:00 |
  | 3  |    M2    |    33333    |     2     |  jimmy  | 2012-06-27 10:22:29 |     0     | 0000-00-00 00:00:00 |
  | 4  |    M3    |    44444    |     2     |  jimmy  | 2012-06-28 09:41:27 |     1     | 2012-06-28 12:40:37 |
  | 5  |    M4    |    11111    |     3     |  anton  | 2012-06-29 15:53:47 |     0     | 0000-00-00 00:00:00 |
  | 6  |    M4    |    22222    |     4     |  steven | 2012-06-29 22:30:02 |     2     | 2012-06-29 22:30:02 |
  </code></pre>
  
  <p>i try to explain what i want..</p>
  
  <p>if updatedby !=0 than select fullname from table user AS updatetor else 0 or something like that .. but i want all 6 rows</p>
  
  <p><strong>i want to receive this result:</strong></p>
  
  <pre><code>| id | maschine | vorrichtung | createdby | creator |      datecreated    | updatedby | updatetor |     dateupdated     |
  | 1  |    M1    |    11111    |     1     |  admin  | 2012-06-23 17:10:25 |     1     |   admin   | 2012-06-23 18:15:20 |
  | 2  |    M1    |    22222    |     1     |  admin  | 2012-06-25 07:50:49 |     0     |      0    | 0000-00-00 00:00:00 |
  | 3  |    M2    |    33333    |     2     |  jimmy  | 2012-06-27 10:22:29 |     0     |      0    | 0000-00-00 00:00:00 |
  | 4  |    M3    |    44444    |     2     |  jimmy  | 2012-06-28 09:41:27 |     1     |   admin   | 2012-06-28 12:40:37 |
  | 5  |    M4    |    11111    |     3     |  anton  | 2012-06-29 15:53:47 |     0     |      0    | 0000-00-00 00:00:00 |
  | 6  |    M4    |    22222    |     4     |  steven | 2012-06-29 22:30:02 |     2     |   jimmy   | 2012-06-29 22:30:02 |
  </code></pre>
  
  <p>is it possible to realize that? 
  thanks for your help :)</p>
  
  <p>regards berni   </p>