{"id":139,"date":"2024-08-07T19:55:05","date_gmt":"2024-08-07T11:55:05","guid":{"rendered":"https:\/\/note.ui11.cc\/?p=139"},"modified":"2024-08-07T19:55:06","modified_gmt":"2024-08-07T11:55:06","slug":"mysql%e7%9a%84limit%e5%85%b3%e9%94%ae%e5%ad%97","status":"publish","type":"post","link":"https:\/\/note.ui11.cc\/index.php\/2024\/08\/07\/mysql%e7%9a%84limit%e5%85%b3%e9%94%ae%e5%ad%97\/","title":{"rendered":"Mysql\u7684limit\u5173\u952e\u5b57"},"content":{"rendered":"\n<p>\u5728MySQL\u4e2d\uff0c<code>LIMIT<\/code>&nbsp;\u5173\u952e\u5b57\u7528\u4e8e\u9650\u5236\u67e5\u8be2\u7ed3\u679c\u7684\u6570\u91cf\u3002\u5b83\u901a\u5e38\u4e0e&nbsp;<code>SELECT<\/code>&nbsp;\u8bed\u53e5\u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u9650\u5236\u8fd4\u56de\u7684\u884c\u6570\u3002<code>LIMIT<\/code>&nbsp;\u53ef\u4ee5\u63a5\u53d7\u4e00\u4e2a\u6216\u4e24\u4e2a\u53c2\u6570\uff0c\u7528\u4e8e\u6307\u5b9a\u67e5\u8be2\u7ed3\u679c\u7684\u8d77\u59cb\u4f4d\u7f6e\u548c\u6570\u91cf\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8bed\u6cd5<\/h3>\n\n\n\n<p><code>LIMIT<\/code>&nbsp;\u5173\u952e\u5b57\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM table_name LIMIT &#91;offset,] row_count;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>offset<\/code>\uff1a\u53ef\u9009\u53c2\u6570\uff0c\u8868\u793a\u4ece\u54ea\u4e00\u884c\u5f00\u59cb\u8fd4\u56de\u7ed3\u679c\u3002\u5982\u679c\u7701\u7565\uff0c<code>offset<\/code>\u00a0\u9ed8\u8ba4\u4e3a0\uff0c\u5373\u4ece\u7b2c\u4e00\u884c\u5f00\u59cb\u3002<\/li>\n\n\n\n<li><code>row_count<\/code>\uff1a\u5fc5\u987b\u53c2\u6570\uff0c\u8868\u793a\u8981\u8fd4\u56de\u7684\u884c\u6570<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u8fd4\u56de\u524d10\u6761\u8bb0\u5f55<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM table_name LIMIT 10;<\/code><\/pre>\n\n\n\n<p>2.<strong>\u8df3\u8fc7\u524d10\u6761\u8bb0\u5f55\uff0c\u8fd4\u56de\u63a5\u4e0b\u6765\u768410\u6761\u8bb0\u5f55<\/strong>\uff1a<\/p>\n\n\n\n<p>SELECT * FROM table_name LIMIT 10, 10;<\/p>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>10<\/code>&nbsp;\u662f&nbsp;<code>offset<\/code>\uff0c\u8868\u793a\u4ece\u7b2c11\u884c\u5f00\u59cb\uff08\u56e0\u4e3a\u7d22\u5f15\u4ece0\u5f00\u59cb\uff09\uff0c<code>10<\/code>&nbsp;\u662f&nbsp;<code>row_count<\/code>\uff0c\u8868\u793a\u8fd4\u56de10\u884c\u6570\u636e\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7528\u9014<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5206\u9875<\/strong>\uff1a<code>LIMIT<\/code>\u00a0\u5173\u952e\u5b57\u5e38\u7528\u4e8e\u5b9e\u73b0\u6570\u636e\u5e93\u67e5\u8be2\u7684\u5206\u9875\u529f\u80fd\uff0c\u901a\u8fc7\u6307\u5b9a\u00a0<code>offset<\/code>\u00a0\u548c\u00a0<code>row_count<\/code>\u00a0\u6765\u83b7\u53d6\u7279\u5b9a\u8303\u56f4\u7684\u8bb0\u5f55\u3002<\/li>\n\n\n\n<li><strong>\u9650\u5236\u7ed3\u679c\u96c6\u5927\u5c0f<\/strong>\uff1a\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u53ea\u9700\u8981\u67e5\u8be2\u7ed3\u679c\u7684\u4e00\u90e8\u5206\uff0c\u4f8b\u5982\uff0c\u83b7\u53d6\u6700\u65b0\u6216\u6700\u65e7\u7684\u8bb0\u5f55\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u6ce8\u610f\u4e8b\u9879<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>LIMIT<\/code>\u00a0\u5173\u952e\u5b57\u5728MySQL\u4e2d\u975e\u5e38\u9ad8\u6548\uff0c\u56e0\u4e3a\u5b83\u5728\u670d\u52a1\u5668\u7aef\u76f4\u63a5\u9650\u5236\u4e86\u8fd4\u56de\u7684\u884c\u6570\uff0c\u51cf\u5c11\u4e86\u7f51\u7edc\u4f20\u8f93\u7684\u6570\u636e\u91cf\u3002<\/li>\n\n\n\n<li>\u5728\u4f7f\u7528\u00a0<code>LIMIT<\/code>\u00a0\u8fdb\u884c\u5206\u9875\u67e5\u8be2\u65f6\uff0c\u5982\u679c\u6570\u636e\u91cf\u5f88\u5927\uff0c<code>offset<\/code>\u00a0\u503c\u8f83\u5927\u53ef\u80fd\u4f1a\u5bfc\u81f4\u67e5\u8be2\u6027\u80fd\u4e0b\u964d\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u5176\u4ed6\u5206\u9875\u6280\u672f\uff0c\u5982\u201c\u952e\u96c6\u5206\u9875\u201d\uff08keyset pagination\uff09\u6216\u201c\u6e38\u6807\u5206\u9875\u201d\uff08cursor pagination\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<p><code>LIMIT<\/code>&nbsp;\u662fMySQL\u4e2d\u975e\u5e38\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u5b83\u4f7f\u5f97\u4ece\u5927\u578b\u6570\u636e\u96c6\u4e2d\u9ad8\u6548\u5730\u68c0\u7d22\u5b50\u96c6\u53d8\u5f97\u7b80\u5355\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select *from emplyee limit 0,10;\n\u8868\u793a\u4ece0\u5f00\u59cb\u67e5\u8be2\uff0c\u67e510\u6761<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728MySQL\u4e2d\uff0cLIMIT&nbsp;\u5173\u952e\u5b57\u7528\u4e8e\u9650\u5236\u67e5\u8be2\u7ed3\u679c\u7684\u6570\u91cf\u3002\u5b83\u901a\u5e38\u4e0e&nbsp;SELECT&#038;nbsp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4],"tags":[],"class_list":["post-139","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-4"],"_links":{"self":[{"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/posts\/139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/comments?post=139"}],"version-history":[{"count":1,"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/posts\/139\/revisions"}],"predecessor-version":[{"id":140,"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/posts\/139\/revisions\/140"}],"wp:attachment":[{"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/media?parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/categories?post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/note.ui11.cc\/index.php\/wp-json\/wp\/v2\/tags?post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}