Home > Software engineering >  how can I make MySQL return a specific number of rows or less for all select queries without limit c
how can I make MySQL return a specific number of rows or less for all select queries without limit c

Time:06-27

I have a MySQL database containing 10,000 records and I want all select queries to return only 30 rows or less without mentioning the limit clause in the queries

is this possible?

CodePudding user response:

You can set SQL_SELECT_LIMIT Documentation

It defines maximum number of rows, that will be returned from SELECT statements.

SET SQL_SELECT_LIMIT = 1;

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

This parameter can be set global or per session.

  • Related