title: How to use mysql stored procedure parameter in JSON_EXTRACT
body: <p>how can i use mysql stored procedure parameter in JSON_EXTRACT.</p>
  
  <p>Table:</p>
  
  <pre><code>SELECT * FROM table1;
  col1: {"a1":{"a11":"101","a12":"102"},"a2":{"a22":"201","a23":"202"}}
  </code></pre>
  
  <p>Store procedure code:</p>
  
  <pre><code>DROP PROCEDURE IF EXISTS my_procedure;
  DELIMITER //
  CREATE PROCEDURE `my_procedure` (IN attr varchar(50))
  BEGIN
    SELECT JSON_EXTRACT(col1, '$.',attr,'.a11') FROM table1;
  END//
  DELIMITER ;
  </code></pre>
  
  <p>Call stored procedure:</p>
  
  <pre><code>call my_procedure('a1');
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 2.
  </code></pre>
  
  <p>If i change the stored procedure code to:</p>
  
  <pre><code>SELECT JSON_EXTRACT(col1, '$.a1.a11') FROM table1; /* this will work*/
  </code></pre>
  
  <p>but want to pass the JSON_EXTRACT path in the stored procedure parameter. I am using mysql 5.7.21
  Thank you.</p>