limit-clause

MYSQL and the LIMIT clause

天大地大妈咪最大 提交于 2019-12-22 11:33:49
问题 I was wondering if adding a LIMIT 1 to a query would speed up the processing? For example... I have a query that will most of the time return 1 result, but will occasionaly return 10's, 100's or even 1000's of records. But I will only ever want the first record. Would the limit 1 speed things up or make no difference? I know I could use GROUP BY to return 1 result but that would just add more computation. Any thoughts gladly accepted! Thanks 回答1: It depends if you have an ORDER BY. An ORDER

MYSQL and the LIMIT clause

ぃ、小莉子 提交于 2019-12-06 10:09:22
I was wondering if adding a LIMIT 1 to a query would speed up the processing? For example... I have a query that will most of the time return 1 result, but will occasionaly return 10's, 100's or even 1000's of records. But I will only ever want the first record. Would the limit 1 speed things up or make no difference? I know I could use GROUP BY to return 1 result but that would just add more computation. Any thoughts gladly accepted! Thanks It depends if you have an ORDER BY. An ORDER BY needs the entire result set anyway, so it can be ordered. If you don't have any ORDER BY it should run

passing LIMIT as parameters to MySQL sproc

谁说我不能喝 提交于 2019-11-27 01:59:30
I'm creating a paging class and need to pass in two parameters to my MySQL stored procedure for the LIMIT clause. I'm passing them in as INTs and trying something like this SELECT * FROM `MyTable` LIMIT MyFirstParamInt, MySecondParamInt it gives me an error when I try and save the sproc though. Is there a way to do this that I'm just missing? Or am I going to have to EVAL the whole query and EXECUTE it? Prior to 5.5.6, LIMIT could not be parameterized in MySQL stored procedures. You'd need to build the query dynamically and execute it. In 5.5.6 and above, you can just pass the stored procs

passing LIMIT as parameters to MySQL sproc

匆匆过客 提交于 2019-11-26 09:51:46
问题 I\'m creating a paging class and need to pass in two parameters to my MySQL stored procedure for the LIMIT clause. I\'m passing them in as INTs and trying something like this SELECT * FROM `MyTable` LIMIT MyFirstParamInt, MySecondParamInt it gives me an error when I try and save the sproc though. Is there a way to do this that I\'m just missing? Or am I going to have to EVAL the whole query and EXECUTE it? 回答1: Prior to 5.5.6, LIMIT could not be parameterized in MySQL stored procedures. You'd