Seems like MySQL can only take numeric constants in the LIMIT syntax

Seems like MySQL can only take numeric constants in the LIMIT syntax. Directly from MySQL documentation:

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
DECLARE M INT;
SET M=N-1;
RETURN (
SELECT DISTINCT Salary from Employee e order by Salary desc LIMIT M, 1
);
END

https://leetcode.com/problems/nth-highest-salary/discuss/53036/Why-using-LIMIT-N-11-will-cause-error

The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).