Is there any size limit on a MySQL query?

hi guys

i have tables which I query with a “huge” query string, and it’s different
each time it run … And it also grows over time.

So, is there any upper limit how large a query string can be?

Sample:

CREATE OR REPLACE VIEW v_view as
SELECT id FROM table_1 UNION
SELECT id FROM table_2 UNION

SELECT id FROM table_n

with n>500000

thank guys