{"id":6197,"date":"2024-11-14T11:24:17","date_gmt":"2024-11-14T03:24:17","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6197\/"},"modified":"2024-11-14T11:24:17","modified_gmt":"2024-11-14T03:24:17","slug":"mysql%e6%95%b0%e6%8d%ae%e8%a1%a8%e5%a6%82%e4%bd%95%e6%9f%a5%e8%af%a2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6197\/","title":{"rendered":"mysql\u6570\u636e\u8868\u5982\u4f55\u67e5\u8be2"},"content":{"rendered":"<blockquote><p>\n  \u67e5\u8be2 mysql \u6570\u636e\u8868\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 select \u8bed\u53e5\u6765\u68c0\u7d22\u8868\u4e2d\u7684\u6570\u636e\u3002\u6b65\u9aa4\u5982\u4e0b\uff1a1. \u5efa\u7acb\u8fde\u63a5\uff1b2. \u7f16\u5199 select \u8bed\u53e5\uff1b3. \u6267\u884c\u8bed\u53e5\uff1b4. \u83b7\u53d6\u7ed3\u679c\uff1b5. \u5173\u95ed\u8fde\u63a5\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/14\/2024061406122317026.jpg\" class=\"aligncenter\" title=\"mysql\u6570\u636e\u8868\u5982\u4f55\u67e5\u8be2\u63d2\u56fe\" alt=\"mysql\u6570\u636e\u8868\u5982\u4f55\u67e5\u8be2\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u67e5\u8be2 MySQL \u6570\u636e\u8868<\/strong><\/p>\n<p><strong>\u56de\u7b54\uff1a<\/strong><br \/>\u67e5\u8be2 MySQL \u6570\u636e\u8868\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 SELECT \u8bed\u53e5\u6765\u68c0\u7d22\u8868\u4e2d\u7684\u6570\u636e\u3002<\/p>\n<p><strong>\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/strong><\/p>\n<p><strong>1. \u5efa\u7acb\u8fde\u63a5<\/strong><br \/>\u9996\u5148\uff0c\u9700\u8981\u5efa\u7acb\u4e0e MySQL \u6570\u636e\u5e93\u7684\u8fde\u63a5\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a<\/p>\n<pre>mysql -u \u7528\u6237\u540d -p \u5bc6\u7801 -h \u4e3b\u673a\u540d -D \u6570\u636e\u5e93\u540d<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u7f16\u5199 SELECT \u8bed\u53e5<\/strong><br \/>SELECT \u8bed\u53e5\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>SELECT \u5217\u540d1, \u5217\u540d2, ...\nFROM \u8868\u540d\n[WHERE \u6761\u4ef6\u8bed\u53e5]\n[ORDER BY \u6392\u5e8f\u8bed\u53e5]\n[LIMIT \u9650\u5236\u6570\u91cf]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li> <strong>\u5217\u540d\uff1a<\/strong>\u8981\u68c0\u7d22\u7684\u5217\u540d\u3002<\/li>\n<li> <strong>\u8868\u540d\uff1a<\/strong>\u8981\u68c0\u7d22\u6570\u636e\u7684\u8868\u540d\u3002<\/li>\n<li> <strong>WHERE\uff1a<\/strong>\u7528\u4e8e\u8fc7\u6ee4\u7ed3\u679c\u7684\u6761\u4ef6\u8bed\u53e5\uff08\u53ef\u9009\uff09\u3002<\/li>\n<li> <strong>ORDER BY\uff1a<\/strong>\u7528\u4e8e\u5bf9\u7ed3\u679c\u8fdb\u884c\u6392\u5e8f\uff08\u53ef\u9009\uff09\u3002<\/li>\n<li> <strong>LIMIT\uff1a<\/strong>\u7528\u4e8e\u9650\u5236\u8fd4\u56de\u7684\u7ed3\u679c\u6570\u91cf\uff08\u53ef\u9009\uff09\u3002<\/li>\n<\/ul>\n<p><strong>3. \u6267\u884c\u8bed\u53e5<\/strong><br \/>\u4f7f\u7528 &gt; \u63d0\u793a\u7b26\u6267\u884c\u67e5\u8be2\u8bed\u53e5\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>mysql&gt; SELECT * FROM customers;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u83b7\u53d6\u7ed3\u679c<\/strong><br \/>\u5982\u679c\u67e5\u8be2\u6210\u529f\u6267\u884c\uff0c\u5c06\u663e\u793a\u4e00\u4e2a\u7ed3\u679c\u8868\u3002\u7ed3\u679c\u8868\u4e2d\u7684\u6bcf\u4e00\u884c\u4ee3\u8868\u8868\u4e2d\u7684\u4e00\u4e2a\u8bb0\u5f55\uff0c\u6bcf\u4e00\u5217\u4ee3\u8868\u8be5\u8bb0\u5f55\u4e2d\u7684\u4e00\u4e2a\u503c\u3002<\/p>\n<p><strong>5. \u5173\u95ed\u8fde\u63a5<\/strong><br \/>\u67e5\u8be2\u5b8c\u6210\u540e\uff0c\u4f7f\u7528 quit \u547d\u4ee4\u5173\u95ed\u4e0e\u6570\u636e\u5e93\u7684\u8fde\u63a5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6570\u636e\u8868\u5982\u4f55\u67e5\u8be2\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>\u67e5\u8be2 mysql \u6570\u636e\u8868\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 select \u8bed\u53e5\u6765\u68c0\u7d22\u8868\u4e2d\u7684\u6570\u636e\u3002\u6b65\u9aa4\u5982\u4e0b\uff1a1. \u5efa\u7acb\u8fde\u63a5\uff1b2. \u7f16\u5199 select \u8bed\u53e5\uff1b3. \u6267\u884c\u8bed\u53e5\uff1b4. \u83b7\u53d6\u7ed3\u679c\uff1b5. \u5173\u95ed\u8fde\u63a5\u3002 \u5982\u4f55\u67e5\u8be2 MySQL \u6570\u636e\u8868 \u56de\u7b54\uff1a\u67e5\u8be2 MySQL \u6570\u636e\u8868\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 SELECT \u8bed\u53e5\u6765\u68c0\u7d22\u8868\u4e2d\u7684\u6570\u636e\u3002 \u8be6\u7ec6\u6b65\u9aa4\uff1a 1. \u5efa\u7acb\u8fde\u63a5\u9996\u5148\uff0c\u9700\u8981\u5efa\u7acb\u4e0e MySQL \u6570\u636e\u5e93\u7684\u8fde\u63a5\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a mysql -u \u7528\u6237\u540d -p \u5bc6\u7801 -h \u4e3b\u673a\u540d -D \u6570\u636e\u5e93\u540d \u767b\u5f55\u540e\u590d\u5236 2. \u7f16\u5199 SELECT \u8bed\u53e5SELECT \u8bed\u53e5\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a SELECT \u5217\u540d1, \u5217\u540d2, &#8230; FROM \u8868\u540d [WHERE \u6761\u4ef6\u8bed\u53e5] [ORDER BY \u6392\u5e8f\u8bed\u53e5] [LIMIT \u9650\u5236\u6570\u91cf] \u767b\u5f55\u540e\u590d\u5236 \u5217\u540d\uff1a\u8981\u68c0\u7d22\u7684\u5217\u540d\u3002 [&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-6197","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6197","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=6197"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6197\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}