title: MySQL conditional table name in JOIN
body: <p>I'm working on intellecual property management system, where I have 2 tables in database - trademark and design.</p>
  
  <p>Then I have such thing as opposition. This means, if someone else has trademark or design, that looks like our's clients one, manager can create new opposition.</p>
  
  <p>For example, I have 3 tables:</p>
  
  <p>trademark:</p>
  
  <pre><code>id 
  name
  </code></pre>
  
  <p>design:</p>
  
  <pre><code>id
  name
  </code></pre>
  
  <p>oppostion:</p>
  
  <pre><code>id
  name
  object_id
  object_table
  </code></pre>
  
  <p>I don't know, to what table opposition is related, but I should have a possibility to make such kind of query:</p>
  
  <pre><code>SELECT id, name, opposition_object.name FROM opposition
  LEFT JOIN (trademark|design) as opposition_object on opposition.object_id =   (trademark|design).id
  </code></pre>
  
  <p>First, I thought about storing table name as object_table column of opposition table, but then I realised I don't know if it will be possible to query table name and, first of all, it's defenitely a bad design.</p>
  
  <p>But I got strucked here and nothing comes to my mind. So does anyone have any ideas how to handle it?</p>