{"id":217807,"date":"2023-12-23T00:35:28","date_gmt":"2023-12-22T16:35:28","guid":{"rendered":"https:\/\/www.idc.net\/help\/217807\/"},"modified":"2023-12-23T00:35:28","modified_gmt":"2023-12-22T16:35:28","slug":"mysql%e4%bd%bf%e7%94%a8%e6%89%8b%e5%86%8c%ef%bc%9a%e4%bd%bf%e7%94%a8limit%e5%85%b3%e9%94%ae%e5%ad%97%e6%8c%87%e5%ae%9a%e8%bf%94%e5%9b%9e%e8%ae%b0%e5%bd%95%e7%9a%84%e6%95%b0%e9%87%8f","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/217807\/","title":{"rendered":"MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528LIMIT\u5173\u952e\u5b57\u6307\u5b9a\u8fd4\u56de\u8bb0\u5f55\u7684\u6570\u91cf"},"content":{"rendered":"<p><title id=\"mysql%e4%bd%bf%e7%94%a8%e6%89%8b%e5%86%8c%ef%bc%9a%e4%bd%bf%e7%94%a8limit%e5%85%b3%e9%94%ae%e5%ad%97%e6%8c%87%e5%ae%9a%e8%bf%94%e5%9b%9e%e8%ae%b0%e5%bd%95%e7%9a%84%e6%95%b0%e9%87%8f-SFiTIdHUXn\">MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528LIMIT\u5173\u952e\u5b57\u6307\u5b9a\u8fd4\u56de\u8bb0\u5f55\u7684\u6570\u91cf<\/title><\/p>\n<h1 id=\"mysql%e4%bd%bf%e7%94%a8%e6%89%8b%e5%86%8c%ef%bc%9a%e4%bd%bf%e7%94%a8limit%e5%85%b3%e9%94%ae%e5%ad%97%e6%8c%87%e5%ae%9a%e8%bf%94%e5%9b%9e%e8%ae%b0%e5%bd%95%e7%9a%84%e6%95%b0%e9%87%8f-SFiTIdHUXn\">MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528LIMIT\u5173\u952e\u5b57\u6307\u5b9a\u8fd4\u56de\u8bb0\u5f55\u7684\u6570\u91cf<\/h1>\n<p>\u5728MySQL\u4e2d\uff0cLIMIT\u5173\u952e\u5b57\u7528\u4e8e\u6307\u5b9a\u67e5\u8be2\u7ed3\u679c\u8fd4\u56de\u7684\u8bb0\u5f55\u6570\u91cf\u3002\u901a\u8fc7\u4f7f\u7528LIMIT\uff0c\u60a8\u53ef\u4ee5\u9650\u5236\u7ed3\u679c\u96c6\u7684\u5927\u5c0f\uff0c\u4ece\u800c\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u5e76\u51cf\u5c11\u6570\u636e\u4f20\u8f93\u91cf\u3002<\/p>\n<h2 id=\"%e8%af%ad%e6%b3%95-SFiTIdHUXn\">\u8bed\u6cd5<\/h2>\n<p>LIMIT\u5173\u952e\u5b57\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>SELECT column1, column2, ...\nFROM table\nLIMIT [offset,] row_count;<\/code><\/pre>\n<p>\u5176\u4e2d\uff0c<code>column1, column2, ...<\/code>\u662f\u60a8\u8981\u67e5\u8be2\u7684\u5217\u540d\uff0c<code>table<\/code>\u662f\u60a8\u8981\u67e5\u8be2\u7684\u8868\u540d\uff0c<code>offset<\/code>\u662f\u8981\u8df3\u8fc7\u7684\u8bb0\u5f55\u6570\u91cf\uff0c<code>row_count<\/code>\u662f\u8981\u8fd4\u56de\u7684\u8bb0\u5f55\u6570\u91cf\u3002<\/p>\n<h2 id=\"%e7%a4%ba%e4%be%8b-SFiTIdHUXn\">\u793a\u4f8b<\/h2>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u540d\u4e3a<code>employees<\/code>\u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u5458\u5de5\u7684\u59d3\u540d\u548c\u85aa\u6c34\u4fe1\u606f\u3002\u6211\u4eec\u60f3\u8981\u67e5\u8be2\u524d5\u540d\u85aa\u6c34\u6700\u9ad8\u7684\u5458\u5de5\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bSQL\u8bed\u53e5\uff1a<\/p>\n<pre><code>SELECT name, salary\nFROM employees\nORDER BY salary DESC\nLIMIT 5;<\/code><\/pre>\n<p>\u4e0a\u8ff0\u67e5\u8be2\u5c06\u8fd4\u56de\u85aa\u6c34\u6700\u9ad8\u76845\u540d\u5458\u5de5\u7684\u59d3\u540d\u548c\u85aa\u6c34\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8offset-SFiTIdHUXn\">\u4f7f\u7528OFFSET<\/h2>\n<p>\u9664\u4e86\u6307\u5b9a\u8fd4\u56de\u8bb0\u5f55\u7684\u6570\u91cf\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528<code>OFFSET<\/code>\u5173\u952e\u5b57\u6765\u6307\u5b9a\u8981\u8df3\u8fc7\u7684\u8bb0\u5f55\u6570\u91cf\u3002\u4f8b\u5982\uff0c\u5982\u679c\u6211\u4eec\u60f3\u8981\u67e5\u8be2\u7b2c6\u5230\u7b2c10\u540d\u85aa\u6c34\u6700\u9ad8\u7684\u5458\u5de5\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bSQL\u8bed\u53e5\uff1a<\/p>\n<pre><code>SELECT name, salary\nFROM employees\nORDER BY salary DESC\nLIMIT 5 OFFSET 5;<\/code><\/pre>\n<p>\u4e0a\u8ff0\u67e5\u8be2\u5c06\u8df3\u8fc7\u524d5\u540d\u85aa\u6c34\u6700\u9ad8\u7684\u5458\u5de5\uff0c\u5e76\u8fd4\u56de\u7b2c6\u5230\u7b2c10\u540d\u5458\u5de5\u7684\u59d3\u540d\u548c\u85aa\u6c34\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e6%80%bb%e7%bb%93-SFiTIdHUXn\">\u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7\u4f7f\u7528MySQL\u7684LIMIT\u5173\u952e\u5b57\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u5730\u6307\u5b9a\u8fd4\u56de\u8bb0\u5f55\u7684\u6570\u91cf\uff0c\u4ece\u800c\u63a7\u5236\u67e5\u8be2\u7ed3\u679c\u7684\u5927\u5c0f\u3002\u8fd9\u5bf9\u4e8e\u4f18\u5316\u67e5\u8be2\u6027\u80fd\u548c\u51cf\u5c11\u6570\u636e\u4f20\u8f93\u91cf\u975e\u5e38\u6709\u7528\u3002<\/p>\n<p>\u5982\u679c\u60a8\u60f3\u4e86\u89e3\u66f4\u591a\u5173\u4e8eMySQL\u7684\u4f7f\u7528\u624b\u518c\uff0c\u8bf7\u8bbf\u95ee\u6211\u4eec\u7684\u5b98\u65b9\u7f51\u7ad9\uff1a<a href=\"https:\/\/idc.net\">https:\/\/idc.net<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528LIMIT\u5173\u952e\u5b57\u6307\u5b9a\u8fd4\u56de\u8bb0\u5f55\u7684\u6570\u91cf MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528LIMIT\u5173\u952e\u5b57\u6307\u5b9a\u8fd4\u56de\u8bb0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[197851],"tags":[],"class_list":["post-217807","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/217807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=217807"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/217807\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=217807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=217807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=217807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}