Home > Software engineering >  how I can make sql_select_limit takes precedence over limit (not the opposite)?
how I can make sql_select_limit takes precedence over limit (not the opposite)?

Time:06-27

I want to force MySQL to make sql_select_limit take precedence over limit clause for any query. for example, I set sql_select_limit=10 and I execute a query like "SELECT * FROM table limit 50" I want as a result 10, not 50

CodePudding user response:

https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_select_limit says:

If a SELECT has a LIMIT clause, the LIMIT takes precedence over the value of sql_select_limit.

That's the behavior supported by MySQL Server.

You would have to change the source code of MySQL Server to make it behave differently.

I suggest you write SQL queries as you would want them to behave.

  • Related