The lateral subquery emulation for MySQL 5.7 currently uses a double nested subquery which is not supported on MySQL. For a lateral subquery that uses a QuerySpec there is another possible emulation which is to simply check in the ON condition if a matching result exists for the correlated subquery i.e. essentially peeling off the double nesting. To support a QuerySpec that uses limit/offset, which is pretty common for lateral subqueries (IMO the main reason to use lateral), we have to add an additional predicate that checks if the amount of rows that come before the currently joined row is between offset and (offset+limit).
The lateral subquery emulation for MySQL 5.7 currently uses a double nested subquery which is not supported on MySQL. For a lateral subquery that uses a
QuerySpec
there is another possible emulation which is to simply check in the ON condition if a matching result exists for the correlated subquery i.e. essentially peeling off the double nesting. To support aQuerySpec
that uses limit/offset, which is pretty common for lateral subqueries (IMO the main reason to use lateral), we have to add an additional predicate that checks if the amount of rows that come before the currently joined row is between offset and (offset+limit).