开发者

mysql limit - a general question

Assuming the query

SELECT * FROM table WHERE a='1' and b='2' and c>'3' and d>'4' and e!='5' and f='6'

returns 10000 results.

My question is, let's say I limit the search to the first 10 results like this:

SELECT * FROM table WHERE a='1' and b='2' and c>'3' and d>'4' and e!='5' and f='6' LIMIT 10

开发者_开发知识库Will mysql search through all the 10000 results or it will stop at the 10th result?


LIMIT will only display the rows specified, based on their position within the resultset. Without an ORDER BY, you're relying on the order the records were inserted.

You'll probably be interested to read about MySQL's ORDER BY/LIMIT performance...


Since there is no ORDER BY, it will stop at the 10th result (after going through as many non-matching rows as necessary). As OMG Ponies says, which 10 rows you get is unspecified.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜