{"id":4276,"date":"2019-05-28T11:25:07","date_gmt":"2019-05-28T03:25:07","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=4276"},"modified":"2019-05-28T11:25:07","modified_gmt":"2019-05-28T03:25:07","slug":"%e7%a5%9e%e5%a5%87%e7%9a%84mysql%e6%8e%92%e5%ba%8f%ef%bc%8c%e7%b4%a2%e5%bc%95%e3%80%81%e4%bc%98%e5%8c%96%e5%99%a8%e4%b8%8elimit","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=4276","title":{"rendered":"\u795e\u5947\u7684MySQL\u6392\u5e8f\uff0c\u7d22\u5f15\u3001\u4f18\u5316\u5668\u4e0eLimit"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">MySQL \u5f88\u6709\u610f\u601d\uff0c\u53d1\u73b0\u6211\u8d8a\u6765\u8d8a\u559c\u6b22\u5b83\u3002\u4e0d\u56e0\u4e3a\u522b\u7684\uff0c\u5c31\u56e0\u4e3a\u540c\u4e8b\u4e00\u4e2a\u95ee\u9898\u82b1\u4e00\u5929\uff0c\u800c\u6211\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u6211\u90fd\u80fd\u591f\u907f\u514d\u3002\u8282\u7ea6\u7684\u65f6\u95f4\uff0c\u6211\u53ef\u4ee5\u7528\u6765\u5b66\u4e60\u5176\u4ed6\u7684\u77e5\u8bc6\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g3gv06jfufj205802xgln.jpg\" alt=\"\" \/><figcaption>\u590f\u5929\u6765\u4e86\uff0c\u642c\u7816\u90fd\u70eb\u624b\u4e86<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u8fd1\u5173\u6ce8\u4e86\u4e00\u4e0b MySQL \u7684 order by \u6392\u5e8f\u529f\u80fd\u3002\u53d1\u73b0\u4e86\u4e00\u4e9b\u5f88\u6709\u610f\u601d\u7684\u4e8b\u60c5\uff0c\u6211\u4eec\u4e00\u8d77\u6765\u5206\u4eab\u4e00\u4e0b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u6392\u5e8f\u5b57\u6bb5\u6709\u7d22\u5f15\uff0c\u65e0\u6761\u4ef6\u67e5\u8be2\u7684\u60c5\u51b5\u4e0b\uff0c\u7adf\u7136\u5947\u6162\u65e0\u6bd4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from xttblog order by name desc;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u9762\u7684\u67e5\u8be2\u8bed\u53e5\u4e2d\uff0cname \u5b57\u6bb5\u6709\u7d22\u5f15\uff0c\u4f46\u662f\u67e5\u8be2\u6548\u679c\u548c\u6ca1\u7d22\u5f15\u4e00\u6837\u3002\u8fd9\u662f\u56e0\u4e3a\u4f18\u5316\u5668\u8ba4\u4e3a\u8d70\u4e8c\u7ea7\u7d22\u5f15\u518d\u53bb\u56de\u8868\u6210\u672c\u6bd4\u5168\u8868\u626b\u63cf\u6392\u5e8f\u66f4\u9ad8\u3002\u6240\u4ee5\u9009\u62e9\u8d70\u5168\u8868\u626b\u63cf\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u5728\u95ee\u9898 1 \u7684\u57fa\u7840\u4e0a\uff0c\u6211\u6dfb\u52a0\u4e00\u4e2a limit\uff0c\u7ed3\u679c\u53c8\u53d8\u5feb\u4e86\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from xttblog order by name desc limit 10;<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g3gv524rhbj206201r3yj.jpg\" alt=\"\" \/><figcaption>SQL \u7684\u7d22\u5f15\u4f18\u5316\u6d41\u7a0b<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u592a\u795e\u5947\u4e86\u3002\u7d27\u7d27\u52a0\u4e86\u4e00\u4e2a limit\uff0c\u6548\u7387\u53d8\u9ad8\u4e86\u3002\u8fd9\u662f\u56e0\u4e3a\u65e0\u6761\u4ef6\u67e5\u8be2\u4e14 order by name limit m \u4e2d m \u503c\u8f83\u5c0f\uff0c\u662f\u53ef\u4ee5\u8d70\u7d22\u5f15\u7684\u3002\u56e0\u4e3a\u4f18\u5316\u5668\u8ba4\u4e3a\u6839\u636e\u7d22\u5f15\u6709\u5e8f\u6027\u53bb\u56de\u8868\u67e5\u6570\u636e\uff0c\u7136\u540e\u5f97\u5230 m \u6761\u6570\u636e\uff0c\u5c31\u53ef\u4ee5\u7ec8\u6b62\u5faa\u73af\uff0c\u90a3\u4e48\u6210\u672c\u6bd4\u5168\u8868\u626b\u63cf\u5c0f\uff0c\u5219\u9009\u62e9\u8d70\u4e8c\u7ea7\u7d22\u5f15\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001\u5728\u95ee\u9898 2 \u7684\u57fa\u7840\u4e0a\uff0c\u6211\u4eec\u518d\u628a name \u4e0a\u7684\u7d22\u5f15\u53bb\u6389\u3002\u7ed3\u679c\u4e5f\u662f\u6bd4\u8f83\u5feb\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u662f\u56e0\u4e3a\uff0c\u5373\u4fbf\u6ca1\u6709\u4e8c\u7ea7\u7d22\u5f15\uff0cMySQL \u9488\u5bf9 order by limit \u4e5f\u505a\u4e86\u4f18\u5316\uff0c\u91c7\u7528\u5806\u6392\u5e8f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4\u3001\u540c\u4e00\u6761 SQL\uff0c\u4e3a\u4ec0\u4e48\u6709\u65f6\u5019\u6392\u5e8f\u5f88\u5feb\uff0c\u6709\u65f6\u5019\u5f88\u6162\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from xttblog where name = '\u4e1a\u4f59\u8349' order by name desc; -- \u6162\nselect * from xttblog where name = '\u4e1a\u4f59\u8349\u516c\u4f17\u53f7' order by name desc; -- \u5feb<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u548c\u626b\u63cf\u7684\u884c\u6570\u6709\u5173\u7cfb\u3002\u5982\u679c\u626b\u63cf\u7684\u884c\u6570\u8fc7\u591a\uff0csort_buffer \u8fd9\u5757\u5185\u5b58\u653e\u4e0d\u4e0b\uff0c\u5c31\u9700\u8981\u8fdb\u884c\u5728\u78c1\u76d8\u4e2d\u6392\u5e8f\uff0c\u4e5f\u5c31\u662f\u6587\u4ef6\u6392\u5e8f\u3002\u5185\u5b58\u548c\u78c1\u76d8\u4e0d\u662f\u4e00\u4e2a\u7ea7\u522b\u7684\u3002\u56e0\u6b64\u6709\u65f6\u5019\u6162\uff0c\u6709\u65f6\u5019\u5feb\uff0c\u662f\u56e0\u4e3a\u6761\u4ef6\u4e0d\u4e00\u6837\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u603b\u7ed3\uff0c\u6392\u5e8f\u65f6\uff0c\u6392\u5e8f\u5b57\u6bb5\u5c3d\u91cf\u52a0\u4e0a\u7d22\u5f15\u3002\u53e6\u5916 limit \u4e5f\u5f88\u91cd\u8981\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u6ce8\u610f where \u6761\u4ef6\u3002\u66f4\u591a\u5173\u4e8e\u6392\u5e8f\u65b9\u9762\u7684\u5185\u5bb9\uff0c\u6211\u540e\u9762\u518d\u4ed4\u7ec6\u8bb2\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=4276\">\u795e\u5947\u7684MySQL\u6392\u5e8f\uff0c\u7d22\u5f15\u3001\u4f18\u5316\u5668\u4e0eLimit<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>MySQL \u5f88\u6709\u610f\u601d\uff0c\u53d1\u73b0\u6211\u8d8a\u6765\u8d8a\u559c\u6b22\u5b83\u3002\u4e0d\u56e0\u4e3a\u522b\u7684\uff0c\u5c31\u56e0\u4e3a\u540c\u4e8b\u4e00\u4e2a\u95ee\u9898\u82b1\u4e00\u5929\uff0c\u800c\u6211\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u6211\u90fd\u80fd\u591f\u907f\u514d [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[83,580,155,156,1452],"class_list":["post-4276","post","type-post","status-publish","format-standard","hentry","category-sql","tag-mysql","tag-mysql----dba","tag-sql","tag-156","tag-1452"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4276"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4276\/revisions"}],"predecessor-version":[{"id":4277,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4276\/revisions\/4277"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}