{"id":5277,"date":"2024-11-14T13:18:44","date_gmt":"2024-11-14T05:18:44","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5277\/"},"modified":"2024-11-14T13:18:44","modified_gmt":"2024-11-14T05:18:44","slug":"mysql%e6%80%8e%e4%b9%88%e7%94%a8limit%e5%88%86%e9%a1%b5","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5277\/","title":{"rendered":"mysql\u600e\u4e48\u7528limit\u5206\u9875"},"content":{"rendered":"<blockquote><p>\n  \u53ef\u4ee5\u4f7f\u7528 limit \u5b50\u53e5\u8fdb\u884c\u5206\u9875\uff0c\u8bed\u6cd5\u4e3a\uff1alimit offset, limit_size\u3002offset\u6307\u5b9a\u8df3\u8fc7\u591a\u5c11\u884c\uff0climit_size\u6307\u5b9a\u8fd4\u56de\u7684\u884c\u6570\u3002\u4f8b\u5982\uff0cselect * from table_name limit 10, 10;\u5c06\u8df3\u8fc710\u884c\uff0c\u8fd4\u56de10\u884c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/26\/2024052618124215694.jpg\" class=\"aligncenter\" title=\"mysql\u600e\u4e48\u7528limit\u5206\u9875\u63d2\u56fe\" alt=\"mysql\u600e\u4e48\u7528limit\u5206\u9875\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u4e2d\u4f7f\u7528 LIMIT \u5206\u9875<\/strong><\/p>\n<p><strong>\u95ee\u9898\uff1a\u5982\u4f55\u4f7f\u7528 MySQL \u7684 LIMIT \u5b50\u53e5\u8fdb\u884c\u5206\u9875\uff1f<\/strong><\/p>\n<p><strong>\u56de\u7b54\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528 LIMIT \u5b50\u53e5\u5206\u9875\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>SELECT * FROM table_name\nLIMIT offset, limit_size<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>offset \u6307\u5b9a\u8981\u8df3\u8fc7\u591a\u5c11\u884c\u3002<\/li>\n<li>limit_size \u6307\u5b9a\u8981\u8fd4\u56de\u7684\u884c\u6570\u3002<\/li>\n<\/ul>\n<p><strong>\u7528\u6cd5\uff1a<\/strong><\/p>\n<p>\u4f8b\u5982\uff0c\u4ee5\u4e0b\u67e5\u8be2\u5c06\u4ece\u7b2c 10 \u884c\u5f00\u59cb\uff0c\u8fd4\u56de 10 \u884c\uff1a<\/p>\n<pre>SELECT * FROM table_name\nLIMIT 10, 10;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8981\u83b7\u53d6\u4e0b\u4e00\u9875\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\uff1a<\/p>\n<pre>SELECT * FROM table_name\nLIMIT 20, 10;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u8df3\u8fc7\u524d 20 \u884c\uff0c\u5e76\u8fd4\u56de\u7b2c 21-30 \u884c\u3002<\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>offset \u548c limit_size \u5fc5\u987b\u4e3a\u975e\u8d1f\u6574\u6570\u3002<\/li>\n<li>\u5982\u679c offset \u5927\u4e8e\u8868\u7684\u884c\u6570\uff0c\u5c06\u4e0d\u4f1a\u8fd4\u56de\u4efb\u4f55\u884c\u3002<\/li>\n<li>\u5982\u679c limit_size \u5927\u4e8e\u8868\u7684\u884c\u6570\uff0c\u5c06\u8fd4\u56de\u5269\u4f59\u7684\u6240\u6709\u884c\u3002<\/li>\n<li>LIMIT \u5b50\u53e5\u53ea\u80fd\u7528\u4e8e SELECT \u8bed\u53e5\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u7528limit\u5206\u9875\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53ef\u4ee5\u4f7f\u7528 limit \u5b50\u53e5\u8fdb\u884c\u5206\u9875\uff0c\u8bed\u6cd5\u4e3a\uff1alimit offset, limit_size\u3002offset\u6307\u5b9a\u8df3\u8fc7\u591a\u5c11\u884c\uff0climit_size\u6307\u5b9a\u8fd4\u56de\u7684\u884c\u6570\u3002\u4f8b\u5982\uff0cselect * from table_name limit 10, 10;\u5c06\u8df3\u8fc710\u884c\uff0c\u8fd4\u56de10\u884c\u3002 MySQL \u4e2d\u4f7f\u7528 LIMIT \u5206\u9875 \u95ee\u9898\uff1a\u5982\u4f55\u4f7f\u7528 MySQL \u7684 LIMIT \u5b50\u53e5\u8fdb\u884c\u5206\u9875\uff1f \u56de\u7b54\uff1a \u4f7f\u7528 LIMIT \u5b50\u53e5\u5206\u9875\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a SELECT * FROM table_name LIMIT offset, limit_size \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a offset \u6307\u5b9a\u8981\u8df3\u8fc7\u591a\u5c11\u884c\u3002 limit_size \u6307\u5b9a\u8981\u8fd4\u56de\u7684\u884c\u6570\u3002 \u7528\u6cd5\uff1a \u4f8b\u5982\uff0c\u4ee5\u4e0b\u67e5\u8be2\u5c06\u4ece\u7b2c 10 \u884c\u5f00\u59cb\uff0c\u8fd4\u56de 10 \u884c\uff1a SELECT * FROM table_name LIMIT 10, 10; \u767b\u5f55\u540e\u590d\u5236 \u8981\u83b7\u53d6\u4e0b\u4e00\u9875\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\uff1a SELECT * FROM [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5277","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5277"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5277\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}