title: How to select from partition while concatenating its name in MySQL
body: <p>I have the same problem like this one:
  <a href="https://stackoverflow.com/questions/28739994/how-to-select-dynamically-in-select-from-table-name-partiton-partition-name">how to select dynamically in select * from &lt;table_name&gt; partiton (Partition name)?</a> but in Mysql.</p>
  
  <p>When using:</p>
  
  <pre><code>select concat('p', year(now()), month(now()));
  </code></pre>
  
  <p>Response is:</p>
  
  <pre><code>+----------------------------------------+
  | concat('p', year(now()), month(now())) |
  +----------------------------------------+
  | p20153                                 |
  +----------------------------------------+
  </code></pre>
  
  <p>When trying to use:</p>
  
  <pre><code>select max(ttime) from table partition(select concat('p', year(now()), month(now()))));
  </code></pre>
  
  <p>I get an error:</p>
  
  <pre><code>ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select concat('p', year(now()), month(now()))))' at line 1
  </code></pre>
  
  <p>of course when trying <code>select max(ttime) from table partition(p20153)</code> works as expected:</p>
  
  <pre><code>root@localhost [tom]&gt; select max(ttime) from table partition(p20153);
  +---------------------+
  | max(ttime)          |
  +---------------------+
  | 2015-03-16 09:54:34 |
  +---------------------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>Notice the dynamic part is the partition name and not the table name.
  Sample data:</p>
  
  <pre><code>root@localhost [tom]&gt; select id, ttime, value from table partition(p20153) limit 10;
  +----------+---------------------+----------+
  | id       | ttime               | value    |
  +----------+---------------------+----------+
  | 13964275 | 2015-03-01 00:05:11 | 16450824 |
  | 13964291 | 2015-03-01 00:08:12 | 15964352 |
  | 13964332 | 2015-03-01 00:09:42 | 14701984 |
  | 13964379 | 2015-03-01 00:13:27 |    26128 |
  | 13964411 | 2015-03-01 00:16:29 | 11073744 |
  | 13964452 | 2015-03-01 00:20:34 | 14747992 |
  | 13964486 | 2015-03-01 00:23:35 |   177800 |
  | 13964507 | 2015-03-01 00:26:36 | 16786408 |
  | 13964542 | 2015-03-01 00:28:28 |  8749552 |
  | 13964571 | 2015-03-01 00:31:30 | 16932344 |
  +----------+---------------------+----------+
  10 rows in set (0.00 sec)
  </code></pre>