title: Use mid and inner join SQL query in VBA excel
body: <p>Please find the below table where i want to execute mid and inner join SQL query.</p>
  
  <p>table 1:-</p>
  
  <p><a href="https://i.stack.imgur.com/8P4fu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8P4fu.png" alt="enter image description here"></a></p>
  
  <p>table 2:-</p>
  
  <p><a href="https://i.stack.imgur.com/jm9f5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jm9f5.png" alt="enter image description here"></a></p>
  
  <p>Please find my below syntax and the respective error's which i am facing on the same.</p>
  
  <p><strong>1st sql query syntax</strong></p>
  
  <pre><code>sql_string = "SELECT [Sheet1$].[Sr], [Sheet2$].[Value], [Name] FROM" &amp; _
  " [Sheet2$] INNER JOIN [Sheet1$] ON" &amp; _
  " [Sheet1$].[Sr]=(SELECT mid([Sheet2$].[Name], INSTR([Sheet2$].[Name],""#""), len([Sheet2$].[Name])) FROM [Sheet2$]);"
  </code></pre>
  
  <p>error on above code.</p>
  
  <p><a href="https://i.stack.imgur.com/XjCAC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XjCAC.png" alt="enter image description here"></a></p>
  
  <p><strong>2nd sql query syntax</strong></p>
  
  <pre><code>sql_string = "SELECT [Sheet1$].[Sr], [Sheet2$].[Value], [Name] FROM " &amp; _
  "(SELECT mid([Sheet2$].[Name], INSTR([Sheet2$].[Name],""#""), len([Sheet2$].[Name]))KeyValue FROM [Sheet2$]) as [Sheet2$]" &amp; _
  " [Sheet2$] INNER JOIN [Sheet1$] ON [Sheet1$].[Sr]=[Sheet2$].KeyValue;"
  </code></pre>
  
  <p>error on above code.</p>
  
  <p><a href="https://i.stack.imgur.com/F7pmf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F7pmf.png" alt="enter image description here"></a></p>
  
  <p>Please guide me on the same. </p>
  
  <p>Please find the expected output.</p>
  
  <p><a href="https://i.stack.imgur.com/QEZUp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QEZUp.png" alt="enter image description here"></a></p>