{"id":5679,"date":"2024-11-14T11:59:47","date_gmt":"2024-11-14T03:59:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5679\/"},"modified":"2024-11-14T11:59:47","modified_gmt":"2024-11-14T03:59:47","slug":"sql%e5%be%aa%e7%8e%af%e8%af%ad%e5%8f%a5%e6%80%8e%e4%b9%88%e5%86%99","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5679\/","title":{"rendered":"sql\u5faa\u73af\u8bed\u53e5\u600e\u4e48\u5199"},"content":{"rendered":"<blockquote><p>\n  sql \u4e2d\u6709\u4e24\u79cd\u5faa\u73af\u8bed\u53e5\uff1awhile \u5faa\u73af\uff1a\u5f53\u6761\u4ef6\u4e3a\u771f\u65f6\u91cd\u590d\u6267\u884c\u8bed\u53e5\u5757\u3002repeat until \u5faa\u73af\uff1a\u53cd\u590d\u6267\u884c\u8bed\u53e5\u5757\uff0c\u76f4\u5230\u6761\u4ef6\u4e3a\u771f\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/30\/2024053020305391842.jpg\" class=\"aligncenter\" title=\"sql\u5faa\u73af\u8bed\u53e5\u600e\u4e48\u5199\u63d2\u56fe\" alt=\"sql\u5faa\u73af\u8bed\u53e5\u600e\u4e48\u5199\u63d2\u56fe\" \/><\/p>\n<p><strong>SQL \u5faa\u73af\u8bed\u53e5<\/strong><\/p>\n<p><strong>SQL \u4e2d\u7684\u5faa\u73af\u8bed\u53e5\u4e3b\u8981\u6709\u4e24\u79cd\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>WHILE \u5faa\u73af\uff1a<\/strong>\u5f53\u6761\u4ef6\u4e3a\u771f\u65f6\uff0c\u53cd\u590d\u6267\u884c\u8bed\u53e5\u5757\u3002<\/li>\n<li> <strong>REPEAT UNTIL \u5faa\u73af\uff1a<\/strong>\u53cd\u590d\u6267\u884c\u8bed\u53e5\u5757\uff0c\u76f4\u5230\u6761\u4ef6\u4e3a\u771f\u3002<\/li>\n<\/ul>\n<p><strong>WHILE \u5faa\u73af<\/strong><\/p>\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><\/p>\n<pre>WHILE condition DO\n  -- \u8bed\u53e5\u5757\nEND WHILE;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>-- \u8ba1\u7b97 1 \u5230 10 \u7684\u548c\nSET @sum = 0;\nSET @i = 1;\nWHILE @i &lt;= 10 DO\n  SET @sum = @sum + @i;\n  SET @i = @i + 1;\nEND WHILE;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>REPEAT UNTIL \u5faa\u73af<\/strong><\/p>\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><\/p>\n<pre>REPEAT\n  -- \u8bed\u53e5\u5757\nUNTIL condition;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>-- \u5faa\u73af\u8bfb\u53d6\u6570\u636e\uff0c\u76f4\u5230\u5230\u8fbe\u6587\u4ef6\u672b\u5c3e\nREPEAT\n  READ data FROM file;\nUNTIL data IS NULL;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u5faa\u73af\u8bed\u53e5\u5fc5\u987b\u4f7f\u7528 END \u5173\u952e\u5b57\u7ec8\u6b62\u3002<\/li>\n<li>\u6761\u4ef6\u8868\u8fbe\u5f0f\u5fc5\u987b\u662f\u5e03\u5c14\u503c\u3002<\/li>\n<li>\u5faa\u73af\u53ef\u80fd\u5bfc\u81f4\u65e0\u9650\u5faa\u73af\uff0c\u56e0\u6b64\u5fc5\u987b\u5c0f\u5fc3\u4f7f\u7528\u3002<\/li>\n<li>\u53ef\u4ee5\u4f7f\u7528 BREAK \u8bed\u53e5\u63d0\u524d\u9000\u51fa\u5faa\u73af\u3002<\/li>\n<li>WHILE \u5faa\u73af\u548c REPEAT UNTIL \u5faa\u73af\u90fd\u53ef\u4ee5\u5305\u542b\u5d4c\u5957\u5faa\u73af\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fsql\u5faa\u73af\u8bed\u53e5\u600e\u4e48\u5199\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>sql \u4e2d\u6709\u4e24\u79cd\u5faa\u73af\u8bed\u53e5\uff1awhile \u5faa\u73af\uff1a\u5f53\u6761\u4ef6\u4e3a\u771f\u65f6\u91cd\u590d\u6267\u884c\u8bed\u53e5\u5757\u3002repeat until \u5faa\u73af\uff1a\u53cd\u590d\u6267\u884c\u8bed\u53e5\u5757\uff0c\u76f4\u5230\u6761\u4ef6\u4e3a\u771f\u3002 SQL \u5faa\u73af\u8bed\u53e5 SQL \u4e2d\u7684\u5faa\u73af\u8bed\u53e5\u4e3b\u8981\u6709\u4e24\u79cd\uff1a WHILE \u5faa\u73af\uff1a\u5f53\u6761\u4ef6\u4e3a\u771f\u65f6\uff0c\u53cd\u590d\u6267\u884c\u8bed\u53e5\u5757\u3002 REPEAT UNTIL \u5faa\u73af\uff1a\u53cd\u590d\u6267\u884c\u8bed\u53e5\u5757\uff0c\u76f4\u5230\u6761\u4ef6\u4e3a\u771f\u3002 WHILE \u5faa\u73af \u8bed\u6cd5\uff1a WHILE condition DO &#8212; \u8bed\u53e5\u5757 END WHILE; \u767b\u5f55\u540e\u590d\u5236 \u793a\u4f8b\uff1a &#8212; \u8ba1\u7b97 1 \u5230 10 \u7684\u548c SET @sum = 0; SET @i = 1; WHILE @i &lt;= 10 DO SET @sum = @sum + @i; SET @i = @i [&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-5679","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5679","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=5679"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5679\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}