title: SELECT * FROM TABLE, TABLE depending on another query - SQL
body: <p>Here's what I'm trying to achieve :
  Select a person's or firm's name depending on the contact type.</p>
  
  <p>Tables :</p>
  
  <pre><code>CONTACTS :               PEOPLE              FIRMS
  - id                     - contact_id        - contact_id    
  - type (person/firm)     - name              - name
  </code></pre>
  
  <p>I would like this kind of magic :</p>
  
  <pre><code>SELECT type 
  FROM contacts 
  WHERE contacts.id = 42;
  
  SELECT model.name 
  FROM contacts LEFT JOIN model ON model.contact_id = contacts.id 
  WHERE contacts_id = 42 
  AND model = CASE (WHEN type = "person" THEN "people" 
                    WHEN type = "firm" THEN "Firms" END); (Not sure this one works)
  </code></pre>
  
  <p>All in one query. Thanks ! </p>