title: Sample with Mysql with dynamic table name
body: <p>Tell me please. It is necessary to make a selection with the database at which the name of the table, from which the sample is made, is formed based on the table prefix and the data that is extracted from the table.</p>
  
  <p>Tables: Sites, Chats and Chat_ID (tables with correspondence).</p>
  
  <p>I need to get the site id and the number of unread from this site. I do this:</p>
  
  <pre><code>SELECT
    s.id AS id,
   (SELECT
     COUNT(*)
    FROM
      HOW TO ET TABLE NAME? AS ch
    WHERE
      ch.chat_id = c.id AND
      status = 0 AND
      type = 'CLIENT'
    ) AS unread
  FROM
    site AS s
    LEFT JOIN chat AS c ON
      c.site_id = s.id AND
      c.operator_id = s.user_id
  WHERE
    s.user_id = 1;
  </code></pre>
  
  <p>The name of the table consists of the prefix and id of the site - chat_1.</p>
  
  <p>Maybe it's not right - do not throw slippers)</p>