{"id":6960,"date":"2022-03-29T15:05:19","date_gmt":"2022-03-29T07:05:19","guid":{"rendered":"https:\/\/vip.fxxkpython.com\/?p=6960"},"modified":"2022-03-29T15:05:21","modified_gmt":"2022-03-29T07:05:21","slug":"%e4%bd%bf%e7%94%a8-python-%e4%bb%8e-0-%e5%bc%80%e5%8f%91%e5%b1%9e%e4%ba%8e%e4%bd%a0%e7%9a%84%e4%b8%aa%e4%ba%ba%e7%ae%a1%e7%90%86%e7%b3%bb%e7%bb%9f-29-%e5%af%b9%e4%ba%8e%e5%a4%8d%e6%9d%82%e6%95%b0","status":"publish","type":"post","link":"https:\/\/vip.fxxkpython.com\/?p=6960","title":{"rendered":"\u4f7f\u7528 Python \u4ece 0 \u5f00\u53d1\u5c5e\u4e8e\u4f60\u7684\u4e2a\u4eba\u7ba1\u7406\u7cfb\u7edf 29 | \u5bf9\u4e8e\u590d\u6742\u6570\u636e\u5e94\u8be5\u5982\u4f55\u5904\u7406\uff1f"},"content":{"rendered":"\n<p>\u4f60\u5728\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5e76\u4e0d\u603b\u662f\u5904\u7406\u7b80\u5355\u7684\u6570\u636e\u4ea4\u4e92\uff0c\u6709\u65f6\u5019\u4f60\u7684\u4e1a\u52a1\u9700\u8981\u5f97\u5230\u6bd4\u8f83\u7279\u6b8a\u7684\u6570\u636e\uff0c\u90a3\u4e48\u5c31\u65e0\u6cd5\u5355\u7eaf\u7684\u4ece model \u4e2d\u8c03\u7528\u7b80\u5355\u7684\u300c\u589e\u5220\u6539\u67e5\u300d\uff0c\u4f60\u8fd8\u9700\u8981\u66f4\u8fd1\u4e00\u6b65\u7684\u5206\u6790\uff0c\u800c\u8fd9\u91cc\u7684\u5206\u6790\u548c\u5b9e\u73b0\uff0c\u4e5f\u662f\u6709\u4e00\u5b9a\u7684\u6280\u5de7\u7684\u3002<\/p>\n\n\n\n<p>\u6bd4\u5982\u4e4b\u524d\u6211\u7ed9\u4f60\u6f14\u793a\u7684\u300c\u4efb\u52a1\u62c6\u5206\u300d\u529f\u80fd\uff0c\u4e00\u4e2a\u5927\u8ba1\u5212\u4e0b\u6709\u591a\u4e2a\u5c0f\u8ba1\u5212\uff0c\u6bcf\u4e00\u4e2a\u5c0f\u8ba1\u5212\u90fd\u6709\u4e00\u4e2a\u662f\u5426\u5b8c\u6210\u7684\u72b6\u6001\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"733\" height=\"288\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53481.37.33.png\" alt=\"\" class=\"wp-image-6961\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53481.37.33.png 733w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53481.37.33-300x118.png 300w\" sizes=\"(max-width: 733px) 100vw, 733px\" \/><\/figure><\/div>\n\n\n\n<p>\u90a3\u4e48\u5728<strong>\u83b7\u53d6\u8ba1\u5212\u5217\u8868\u7684\u65f6\u5019\uff0c\u6211\u4eec\u60f3\u8981\u53ea\u83b7\u53d6\u90a3\u4e9b\u672a\u5b8c\u6210\u7684\u5927\u8ba1\u5212\u6570\u636e<\/strong>\uff0c\u5e94\u8be5\u600e\u4e48\u83b7\u5f97\u5462\uff1f\u5982\u679c\u8fd9\u65f6\u6211\u4eec\u76f4\u63a5\u4ece\u4ee3\u7801\u4e0b\u624b\uff0c\u53ef\u80fd\u4f1a\u6655\u5934\u8f6c\u5411\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u6211\u4eec\u6765\u601d\u8003\u4e00\u4e2a\u95ee\u9898\uff0c\u60f3\u8981\u5f97\u5230\u4e00\u4e2a\u672a\u5b8c\u6210\u7684\u5927\u8ba1\u5212\u5217\u8868\uff0c\u6211\u4eec\u5c31\u8981\u5f97\u5230\u6bcf\u4e00\u4e2a\u5927\u8ba1\u5212\u662f\u5426\u5b8c\u6210\uff0c\u800c\u60f3\u8981\u77e5\u9053\u6bcf\u4e2a\u5927\u8ba1\u5212\u662f\u5426\u5b8c\u6210\uff0c\u6211\u4eec\u5c31\u5f97\u77e5\u9053\u6bcf\u4e2a\u5927\u8ba1\u5212\u4e0b\u7684\u6240\u6709\u5b50\u8ba1\u5212\u662f\u5426\u90fd\u5b8c\u6210\u3002\u56e0\u4e3a\u53ea\u6709\u6240\u6709\u7684\u5b50\u8ba1\u5212\u90fd\u5b8c\u6210\u4e86\uff0c\u624d\u8bf4\u660e\u8fd9\u4e2a\u5927\u8ba1\u5212\u662f\u5b8c\u6210\u4e86\u7684\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"952\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53481.59.35-1024x952.png\" alt=\"\" class=\"wp-image-6964\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53481.59.35-1024x952.png 1024w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53481.59.35-300x279.png 300w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53481.59.35-768x714.png 768w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53481.59.35-1536x1429.png 1536w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53481.59.35-769x715.png 769w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53481.59.35.png 2030w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>\u90a3\u4e48\u6211\u4eec\u5f88\u5feb\u5c31\u628a\u76ee\u5149\u7684\u7126\u70b9\u8f6c\u5411\uff1a\u5c0f\u8ba1\u5212\u3002<\/p>\n\n\n\n<p>\u5c31\u4ece\u6700\u7b80\u5355\u7684\u5f00\u59cb\uff0c\u67e5\u8be2\u5f53\u524d\u7528\u6237\u7684\u6240\u6709\u5c0f\u8ba1\u5212\u6570\u636e\uff1a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;wpum_restrict_type&quot;:&quot;wpum_restrict_type_state&quot;,&quot;wpum_hide_state_in&quot;:false,&quot;wpum_hide_state_out&quot;:false,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">select * from sub_plan where user_id = 12;<\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"407\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.05.13-1024x407.png\" alt=\"\" class=\"wp-image-6965\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.05.13-1024x407.png 1024w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.05.13-300x119.png 300w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.05.13-768x305.png 768w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.05.13-1536x610.png 1536w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.05.13-769x305.png 769w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.05.13.png 1679w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u8fd9\u5f20\u8868\u7684\u8bb0\u5f55\u4e2d\uff0c\u6709\u4e2a plan_id \u5b57\u6bb5\uff0c\u5c31\u662f\u5bf9\u5e94\u7684\u5927\u8ba1\u5212\u7684 id\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7 group by\uff0c \u5c31\u53ef\u4ee5\u5f97\u5230\u6240\u6709\u5927\u8ba1\u5212\u7684 id\uff1a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;wpum_restrict_type&quot;:&quot;wpum_restrict_type_state&quot;,&quot;wpum_hide_state_in&quot;:false,&quot;wpum_hide_state_out&quot;:false,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">select plan_id from sub_plan where user_id=12 group by plan_id;<\/pre><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"768\" height=\"514\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.13.11.png\" alt=\"\" class=\"wp-image-6966\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.13.11.png 768w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.13.11-300x201.png 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure><\/div>\n\n\n\n<p>\u90a3\u4e48\u5728\u8fd9\u91cc\u5224\u65ad\u54ea\u4e9b plan_id \u7684\u90fd\u662f\u5b8c\u6210\u7684\u4e0d\u5c31\u597d\u4e86\u4e48\uff1f<\/p>\n\n\n\n<p>\u6211\u4eec\u4e4b\u524d\u5c31\u5b9a\u4e49\u8fc7\uff0c\u5c0f\u8ba1\u5212\u7684 is_done \u5b57\u6bb5\u662f\u6765\u5224\u65ad\u5b83\u7684\u5b8c\u6210\u72b6\u6001\u7684\uff0c0\u8868\u793a\u672a\u5b8c\u6210\uff0c1 \u8868\u793a\u5df2\u7ecf\u5b8c\u6210\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u662f\u4e0d\u662f\u628a\u4e00\u4e2a\u5927\u8ba1\u5212\u4e0b\u7684\u6240\u6709\u5b50\u8ba1\u5212\u7684 is_done \u52a0\u8d77\u6765\uff0c\u518d\u9664\u4ee5\u6240\u6709\u5b50\u8ba1\u5212\u7684\u6570\u76ee\uff0c\u5982\u679c\u5c0f\u4e8e 1 \uff0c\u90a3\u4e48\u5c31\u662f\u8bf4\u660e\u8fd9\u4e2a\u5927\u8ba1\u5212\u662f\u672a\u5b8c\u6210\u7684\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u5c31\u53ef\u4ee5\u8fd9\u4e48\u67e5\u8be2\uff0c\u5f97\u5230\u672a\u5b8c\u6210\u7684\u5927\u8ba1\u5212 id\uff1a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;wpum_restrict_type&quot;:&quot;wpum_restrict_type_state&quot;,&quot;wpum_hide_state_in&quot;:false,&quot;wpum_hide_state_out&quot;:false,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">select plan_id from sub_plan where user_id=12 group by plan_id having (sum(is_done)\/count(*) &lt; 1)<\/pre><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"948\" height=\"498\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.22.04.png\" alt=\"\" class=\"wp-image-6967\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.22.04.png 948w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.22.04-300x158.png 300w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.22.04-768x403.png 768w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.22.04-769x404.png 769w\" sizes=\"(max-width: 948px) 100vw, 948px\" \/><\/figure><\/div>\n\n\n\n<p>\u73b0\u5728\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 sub_plan \u8fd9\u5f20\u8868\u5f97\u5230\u300c\u6240\u6709\u5927\u8ba1\u5212\u7684id\u300d\u4ee5\u53ca\u300c\u6240\u6709\u672a\u5b8c\u6210\u7684\u5927\u8ba1\u5212id\u300d\u3002\u90a3\u6211\u4eec\u5c31\u53ef\u4ee5\u6839\u636e\u5b83\u4eec\u4f5c\u4e3a\u300c\u6761\u4ef6\u300d\uff0c\u5728\u5927\u8ba1\u5212 plan \u8868\u4e2d\u505a\u67e5\u8be2\u3002<\/p>\n\n\n\n<p>\u6709\u4e00\u70b9\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6211\u4eec\u5728\u521b\u5efa\u5927\u8ba1\u5212\u7684\u65f6\u5019\uff0c\u6709\u4e9b\u6211\u4eec\u53ef\u80fd\u8fd8\u6ca1\u6709\u521b\u5efa\u5c0f\u8ba1\u5212\uff08sub_plan\u6ca1\u6709\u8bb0\u5f55\uff09\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"291\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.54.05-1024x291.png\" alt=\"\" class=\"wp-image-6970\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.54.05-1024x291.png 1024w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.54.05-300x85.png 300w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.54.05-768x218.png 768w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.54.05-1536x436.png 1536w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.54.05-769x218.png 769w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.54.05.png 2014w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>\u6240\u4ee5\u8fd9\u4e2a\u5927\u8ba1\u5212\u4e5f\u662f\u5c5e\u4e8e\u672a\u5b8c\u6210\u72b6\u6001\u7684\uff0c\u90a3\u4e48\u8fd9\u65f6\u5019\u7684\u5927\u8ba1\u5212 id \u5c31\u4e0d\u5728 \u300e\u901a\u8fc7 sub_plan \u8fd9\u5f20\u8868\u5f97\u5230\u300c\u6240\u6709\u5927\u8ba1\u5212\u7684id\u300d\u300f\u4e2d\u3002<\/p>\n\n\n\n<p>\u73b0\u5728\u8981\u83b7\u53d6\u5f53\u524d\u7528\u6237\u6240\u6709\u672a\u5b8c\u6210\u7684\u5927\u8ba1\u5212\u5217\u8868\u5c31\u53ef\u4ee5\u8fd9\u6837\u67e5\u8be2\uff1a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;wpum_restrict_type&quot;:&quot;wpum_restrict_type_state&quot;,&quot;wpum_hide_state_in&quot;:false,&quot;wpum_hide_state_out&quot;:false,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">select * from plan where user_id=12 and (id not in (select plan_id from sub_plan where user_id=12) or id in(select plan_id from sub_plan where user_id=12 group by plan_id having sum(is_done)\/count(*) &lt; 1)) order by create_at desc;<\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"289\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.29.53-1024x289.png\" alt=\"\" class=\"wp-image-6968\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.29.53-1024x289.png 1024w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.29.53-300x85.png 300w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.29.53-768x217.png 768w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.29.53-1536x433.png 1536w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.29.53-769x217.png 769w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.29.53.png 1836w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u4e5f\u5c31\u662f\u901a\u8fc7\u67e5\u8be2\u5927\u8ba1\u5212\u8868\uff0c\u53ea\u8981 id \u5728\u5c0f\u8ba1\u5212\u8868\u4e2d\u4e0d\u5b58\u5728\u7684\uff0c\u4ee5\u53ca\u5728\u5c0f\u8ba1\u5212\u8868\u4e2d\u53d1\u73b0\u6ca1\u6709\u300c\u6240\u6709\u5b50\u8ba1\u5212\u300d\u90fd\u5b8c\u6210\u7684\uff0c\u90a3\u4e48\u5c31\u8bf4\u660e\u8fd9\u4e2a\u5927\u8ba1\u5212\u6ca1\u6709\u5b8c\u6210\u3002<\/p>\n\n\n\n<p>\u8fd9\u6837\u901a\u8fc7\u6700\u5c0f\u5355\u4f4d\u7684\u5206\u6790\uff0c\u53cd\u5411\u83b7\u5f97\u67e5\u8be2\u7684\u5b50\u6761\u4ef6\uff0c\u4ece\u800c\u83b7\u5f97\u6211\u4eec\u60f3\u8981\u7684\u6570\u636e\u3002\u5c31\u6bd4\u8f83\u5bb9\u6613\u4e00\u4e9b\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u63a5\u4e0b\u6765\uff0c\u5c31\u8981\u5c06\u8fd9\u6837\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u901a\u8fc7 sqlalchemy\uff0c\u7528\u9762\u5411\u5bf9\u8c61\u7684\u65b9\u5f0f\u8868\u8fbe\u5b83\u4eec\u3002<\/p>\n\n\n\n<p>\u6309\u7167\u6211\u4eec\u521a\u521a\u7684\u601d\u8def\uff0c\u5148\u628a\u5b50\u6761\u4ef6\u5199\u51fa\u6765\u3002<\/p>\n\n\n\n<p>\u5728 sqlalchemy \u4e2d\u5199\u5b50\u67e5\u8be2\uff0c\u53ef\u4ee5\u8c03\u7528\u5b83\u7684 subquery \u65b9\u6cd5\uff0c\u50cf\u8fd9\u6837\u83b7\u53d6\u5b50\u8ba1\u5212\u8868\u4e2d\u7684\u5927\u8ba1\u5212id\uff1a<\/p>\n\n\n\n<p>sql \u662f\u8fd9\u6837\u7684\uff1a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;wpum_restrict_type&quot;:&quot;wpum_restrict_type_state&quot;,&quot;wpum_hide_state_in&quot;:false,&quot;wpum_hide_state_out&quot;:false,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">select plan_id from sub_plan where user_id=12 group by plan_id;<\/pre><\/div>\n\n\n\n<p>\u90a3\u4e48\u4ee3\u7801\u5c31\u662f\u8fd9\u6837\uff1a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;wpum_restrict_type&quot;:&quot;wpum_restrict_type_state&quot;,&quot;wpum_hide_state_in&quot;:false,&quot;wpum_hide_state_out&quot;:false,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">subquery_all_subplan = db.session.query(SubPlan.plan_id) \\                \n      \u00a6   \u00a6   \u00a6   \u00a6   \u00a6   \u00a6   \u00a6   \u00a6   \u00a6.filter(SubPlan.user_id == current_user.id) \\  \n      \u00a6   \u00a6   \u00a6   \u00a6   \u00a6   \u00a6   \u00a6   \u00a6   \u00a6.subquery()  <\/pre><\/div>\n\n\n\n<p>\u83b7\u53d6\u5b50\u8ba1\u5212\u8868\u4e2d\u6240\u6709\u672a\u5b8c\u6210\u7684\u5927\u8ba1\u5212id\uff1a<div style=\"text-align:center;border:1px dashed #FF9A9A;padding:8px;margin:10px auto;color:#FF6666;\">\u672c\u6587\u9690\u85cf\u5185\u5bb9 <a href=\"https:\/\/vip.fxxkpython.com\/wp-login.php?redirect_to=https%3A%2F%2Fvip.fxxkpython.com%2F%3Fp%3D6960\">\u767b\u9646<\/a> \u540e\u624d\u53ef\u4ee5\u6d4f\u89c8<\/div>\u8fd0\u884c\u8d77\u6765\u5c31\u662f\u5f97\u5230\u6240\u6709\u672a\u5b8c\u6210\u7684\u6570\u636e\u4e86\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"855\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.57.56-1024x855.png\" alt=\"\" class=\"wp-image-6972\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.57.56-1024x855.png 1024w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.57.56-300x250.png 300w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.57.56-768x641.png 768w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.57.56-1536x1282.png 1536w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.57.56-2048x1709.png 2048w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2022\/03\/\u622a\u5c4f2022-03-29-\u4e0b\u53482.57.56-769x642.png 769w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>\u6240\u8c13\u5927\u4e8b\u5316\u5c0f\uff0c\u5c0f\u4e8b\u5316\u4e86\uff0c\u5c31\u662f\u8fd9\u4e48\u4e2a\u7406\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u5728\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5e76\u4e0d\u603b\u662f\u5904\u7406\u7b80\u5355\u7684\u6570\u636e\u4ea4\u4e92\uff0c\u6709\u65f6\u5019\u4f60\u7684\u4e1a\u52a1\u9700\u8981\u5f97\u5230\u6bd4\u8f83\u7279\u6b8a\u7684\u6570\u636e\uff0c\u90a3\u4e48\u5c31\u65e0\u6cd5\u5355\u7eaf\u7684\u4ece model \u4e2d\u8c03\u7528\u7b80\u5355\u7684\u300c\u589e\u5220\u6539\u67e5\u300d\uff0c\u4f60\u8fd8\u9700\u8981\u66f4\u8fd1\u4e00\u6b65\u7684\u5206\u6790\uff0c\u800c\u8fd9\u91cc\u7684\u5206\u6790\u548c\u5b9e\u73b0\uff0c\u4e5f\u662f\u6709\u4e00\u5b9a\u7684\u6280\u5de7\u7684\u3002 \u6bd4\u5982\u4e4b\u524d\u6211\u7ed9\u4f60\u6f14\u793a\u7684\u300c\u4efb\u52a1\u62c6\u5206\u300d\u529f\u80fd\uff0c\u4e00\u4e2a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":6961,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[638,99],"tags":[549,576,639,640],"_links":{"self":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6960"}],"collection":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6960"}],"version-history":[{"count":2,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6960\/revisions"}],"predecessor-version":[{"id":6973,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6960\/revisions\/6973"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/media\/6961"}],"wp:attachment":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}