Tableau doesn't support these type of queries when you connect with mySQL. You should try to reformat this with nested subquery in Tableau.
So the query should be a single query that will give a result set. Custom SQL query will be wrapped in subquery inside the Tableau. You will get the errors if your SQL can't be treated in that way.
"initial SQL" allows you to run any SQL upfront, create temporary tables etc.
After evaluation of initial SQL, you can write a query as a part of the connection and took advantage of the objects that are created in initial SQL.
To learn more about Tableau check tableau certification.