{"id":4631,"date":"2020-01-11T11:51:20","date_gmt":"2020-01-11T03:51:20","guid":{"rendered":"https:\/\/www.xttblog.com\/?p=4631"},"modified":"2020-01-11T11:51:20","modified_gmt":"2020-01-11T03:51:20","slug":"%e4%bb%8e%e6%a0%b9%e4%b8%8a%e7%90%86%e8%a7%a3order-by-limit%e5%88%86%e9%a1%b5%e6%95%b0%e6%8d%ae%e9%87%8d%e5%a4%8d%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=4631","title":{"rendered":"\u4ece\u6839\u4e0a\u7406\u89e3order by limit\u5206\u9875\u6570\u636e\u91cd\u590d\u95ee\u9898"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u95ee\u9898\u76f8\u4fe1\u4e0d\u5c11\u4eba\u90fd\u9047\u5230\u8fc7\uff0c\u4f46\u5f88\u5c11\u6709\u4eba\u8ffd\u6839\u6eaf\u6e90\u3002\u4eca\u5929\u6211\u62bd\u51fa\u4e00\u70b9\u65f6\u95f4\uff0c\u6765\u8ba8\u8bba\u8ba8\u8bba order by + limit \u5728\u4ec0\u4e48\u60c5\u51b5\u4e0b\u4f1a\u51fa\u73b0\u5206\u9875\u6570\u636e\u91cd\u590d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6628\u5929\u5728\u201cCTO\u201d\u7fa4\u63d0\u95ee\u4e86\u4e4b\u540e\uff0c\u4e0d\u5c11\u5927\u795e\u90fd\u56de\u7b54\u7684\u76f8\u5f53\u6b63\u786e\u3002\u6211\u8fd9\u91cc\u7ed3\u5408\u4e00\u4e0b\u4ed6\u4eec\u7684\u56de\u7b54\uff0c\u5e76\u8865\u5145\u4e00\u4e9b\u5185\u5bb9\u5206\u4eab\u7ed9\u5927\u5bb6\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6392\u5e8f\u79bb\u4e0d\u5f00\u7b97\u6cd5\uff0c\u5728\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e2d\uff0c\u5f80\u5f80\u4f1a\u5b58\u5728\u591a\u79cd\u6392\u5e8f\u7b97\u6cd5\u3002\u901a\u8fc7 MySQL \u7684\u6e90\u7801\u548c\u5b98\u65b9\u6587\u6863\u4ecb\u7ecd\u53ef\u4ee5\u5f97\u77e5\uff0c\u5b83\u7684\u6392\u5e8f\u89c4\u5f8b\u53ef\u4ee5\u603b\u7ed3\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u5f53 order by \u4e0d\u80fd\u4f7f\u7528\u7d22\u5f15\u8fdb\u884c\u6392\u5e8f\u65f6\uff0c\u5c06\u4f7f\u7528\u6392\u5e8f\u7b97\u6cd5\u8fdb\u884c\u6392\u5e8f\uff1b<\/li><li>\u82e5\u6392\u5e8f\u5185\u5bb9\u80fd\u5168\u90e8\u653e\u5165\u5185\u5b58\uff0c\u5219\u4ec5\u5728\u5185\u5b58\u4e2d\u4f7f\u7528\u5feb\u901f\u6392\u5e8f\uff1b<\/li><li>\u82e5\u6392\u5e8f\u5185\u5bb9\u4e0d\u80fd\u5168\u90e8\u653e\u5165\u5185\u5b58\uff0c\u5219\u5206\u6279\u6b21\u5c06\u6392\u597d\u5e8f\u7684\u5185\u5bb9\u653e\u5165\u6587\u4ef6\uff0c\u7136\u540e\u5c06\u591a\u4e2a\u6587\u4ef6\u8fdb\u884c\u5f52\u5e76\u6392\u5e8f\uff1b<\/li><li>\u82e5\u6392\u5e8f\u4e2d\u5305\u542b limit \u8bed\u53e5\uff0c\u5219\u4f7f\u7528\u5806\u6392\u5e8f\u4f18\u5316\u6392\u5e8f\u8fc7\u7a0b\u3002<br><\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4ed6\u5982\uff1aPG\uff0cMariaDB\uff0cAliSQL\uff0cSQL Server \u7b49\u6392\u5e8f\u7b97\u6cd5\u65b9\u9762\u5dee\u522b\u4e0d\u5927\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6839\u636e\u4e0a\u9762\u7684\u603b\u7ed3\uff0c\u5f53\u4f60\u7684 order by limit \u5206\u9875\u51fa\u73b0\u6570\u636e\u91cd\u590d\u3002\u6bd4\u5982\uff0c\u4e00\u4e2a\u7528\u6237\u8868\uff0c\u5f53\u4f7f\u7528 limit 5 \u540e\u51fa\u73b0\u4e00\u4e2a\u5f20\u4e09\u3002\u518d\u4f7f\u7528 limit 5,10\u00a0\u7684\u65f6\u5019\uff0c\u5f20\u4e09\u53c8\u51fa\u73b0\u4e86\u3002\u6ce8\u610f\uff0c\u8fd9\u4e24\u4e2a\u5f20\u4e09\u662f\u540c\u4e00\u4e2a\u4eba\uff0cid \u662f\u76f8\u540c\u7684\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u7684 order by \u80af\u5b9a\u662f\u6ca1\u6709\u4f7f\u7528\u7d22\u5f15\u7684\u3002\u56e0\u4e3a\u4f7f\u7528\u4e86\u7d22\u5f15\uff0c\u5c31\u4f1a\u8fdb\u884c\u7d22\u5f15\u6392\u5e8f\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/img-bbs.csdn.net\/upload\/202001\/11\/1578714166_325174.png\" alt=\"\" \/><figcaption>order by limit \u5206\u9875\u51fa\u73b0\u6570\u636e\u91cd\u590d<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u6839\u636e\u5b98\u65b9\u6587\u6863\u663e\u793a\uff0c\u4ee5\u53ca\u6211\u4e0a\u9762\u7684\u603b\u7ed3\uff0c\u53ef\u4ee5\u5f97\u51fa\u3002\u4e0a\u9762\u7684 SQL \u4f7f\u7528\u4e86\u5806\u6392\u5e8f\u3002\u56e0\u4e3a\uff0ccategory \u6ca1\u7d22\u5f15\uff0c\u6240\u4ee5\u6ca1\u8d70\u7d22\u5f15\u6392\u5e8f\uff1b\u5176\u4e8c\u6211\u4eec\u4f7f\u7528\u4e86 limit\uff0c\u6240\u4ee5\u6700\u7ec8\u4f7f\u7528\u4e86\u5806\u6392\u5e8f\u3002\u800c\u4e86\u89e3\u7b97\u6cd5\u7684\u670b\u53cb\u90fd\u77e5\u9053\uff0c\u5806\u6392\u5e8f\u662f\u4e0d\u7a33\u5b9a\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bd4\u5982\uff0c\u6211\u4eec\u73b0\u5728\u6709\u4e0b\u9762\u4e00\u5217\u6570\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/img-bbs.csdn.net\/upload\/202001\/11\/1578714165_961182.png\" alt=\"\" \/><figcaption>\u5806\u6392\u5e8f<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3a\u4e86\uff0c\u770b\u6e05\u4e24\u4e2a 2 \u7684\u533a\u522b\uff0c\u6211\u5206\u522b\u7ed9\u5b83\u4eec\u591a\u6807\u4e86\u4e00\u4e2a\u6570\u5b57\u3002<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u90a3\u4e48\u4f7f\u7528\u5806\u6392\u5e8f\u7684\u7ed3\u679c\uff0c\u53ef\u80fd\u4f1a\u5b58\u5728\u4e0b\u9762\u7684\u7ed3\u679c\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/img-bbs.csdn.net\/upload\/202001\/11\/1578714165_642865.png\" alt=\"\" \/><figcaption>\u5806\u6392\u5e8f\u7ed3\u679c\u4e0d\u7a33\u5b9a<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u79cd\u4e0d\u7a33\u5b9a\u6027\uff0c\u6307\u7684\u5c31\u662f\u591a\u6b21\u6392\u5e8f\u540e\uff0c\u5404\u4e2a\u6570\u7684\u76f8\u5bf9\u4f4d\u7f6e\u53d1\u751f\u4e86\u53d8\u5316\u3002<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9664\u4e86\u5806\u6392\u5e8f\uff0c\u4e0d\u7a33\u5b9a\u7684\u6392\u5e8f\u8fd8\u6709\u4e0b\u9762\u8fd9\u4e9b\u6392\u5e8f\u7b97\u6cd5\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/img-bbs.csdn.net\/upload\/202001\/11\/1578714165_342274.png\" alt=\"\" \/><figcaption>\u4e0d\u7a33\u5b9a\u7684\u6392\u5e8f\u7b97\u6cd5<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u90a3\u4e48\u5982\u4f55\u89e3\u51b3 order by limit \u5206\u9875\u6570\u636e\u91cd\u590d\u95ee\u9898\u5462\uff1f\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u6211\u8fd9\u91cc\u5217\u4e3e\u6700\u5e38\u7528\u7684\u4e24\u79cd\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e00\u79cd\u5c31\u662f\uff0c\u5728\u6392\u5e8f\u4e2d\u52a0\u4e0a\u552f\u4e00\u503c\uff0c\u6bd4\u5982\u4e3b\u952e id\uff0c\u8fd9\u6837\u7531\u4e8e id \u662f\u552f\u4e00\u7684\uff0c\u5c31\u80fd\u786e\u4fdd\u53c2\u4e0e\u6392\u5e8f\u7684 key \u503c\u4e0d\u76f8\u540c\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/img-bbs.csdn.net\/upload\/202001\/11\/1578714166_131172.png\" alt=\"\" \/><figcaption>\u89e3\u51b3 order by limit \u5206\u9875\u6570\u636e\u91cd\u590d\u95ee\u9898<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e8c\u79cd\u5c31\u662f\u907f\u514d\u4f7f\u7528\u5806\u6392\u5e8f\uff0c\u8ba9 order by \u6839\u636e\u7d22\u5f15\u6765\u6392\u5e8f\u3002\u8bf4\u767d\u4e86\uff0c\u5c31\u662f order by \u540e\u9762\u7684\u5b57\u6bb5\u8981\u6709\u7d22\u5f15\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0a\uff0c\u77e5\u9053\u7684\u8d8a\u591a\uff0c\u4e0d\u77e5\u9053\u7684\u5c31\u8d8a\u591a\uff0c\u4e1a\u4f59\u7684\u5c31\u50cf\u4e00\u68f5\u5c0f\u8349\u4e00\u6837\uff01<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" aria-label=\"https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/order-by-optimization.html\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/order-by-optimization.html\" target=\"_blank\">https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/order-by-optimization.html<\/a><\/li><li><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/limit-optimization.html\">https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/limit-optimization.html<\/a><\/li><li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Sorting_algorithm\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"https:\/\/en.wikipedia.org\/wiki\/Sorting_algorithm\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\">https:\/\/en.wikipedia.org\/wiki\/Sorting_algorithm<\/a><\/li><\/ul>\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=4631\">\u4ece\u6839\u4e0a\u7406\u89e3order by limit\u5206\u9875\u6570\u636e\u91cd\u590d\u95ee\u9898<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4e2a\u95ee\u9898\u76f8\u4fe1\u4e0d\u5c11\u4eba\u90fd\u9047\u5230\u8fc7\uff0c\u4f46\u5f88\u5c11\u6709\u4eba\u8ffd\u6839\u6eaf\u6e90\u3002\u4eca\u5929\u6211\u62bd\u51fa\u4e00\u70b9\u65f6\u95f4\uff0c\u6765\u8ba8\u8bba\u8ba8\u8bba order by + limi [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,12],"tags":[823,171,821,172,174],"class_list":["post-4631","post","type-post","status-publish","format-standard","hentry","category-java","category-sql","tag-823","tag-171","tag-821","tag-172","tag-174"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4631","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=4631"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4631\/revisions"}],"predecessor-version":[{"id":4632,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4631\/revisions\/4632"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}