{"id":230925,"date":"2020-12-28T22:08:09","date_gmt":"2020-12-28T14:08:09","guid":{"rendered":"http:\/\/4563.org\/?p=230925"},"modified":"2020-12-28T22:08:09","modified_gmt":"2020-12-28T14:08:09","slug":"%e5%a4%a7%e4%bd%ac%e4%bb%ac%e6%9d%a5%e5%b8%ae%e5%b8%ae%e5%bf%99%ef%bc%81%e8%af%b7%e6%95%99%e4%b8%aa-sql-%e4%b8%8d%e7%9f%a5%e9%81%93%e5%92%8b%e5%86%99%e3%80%82%e3%80%82%e3%80%82","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=230925","title":{"rendered":"\u5927\u4f6c\u4eec\u6765\u5e2e\u5e2e\u5fd9\uff01\u8bf7\u6559\u4e2a SQL \u4e0d\u77e5\u9053\u548b\u5199\u3002\u3002\u3002"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5927\u4f6c\u4eec\u6765\u5e2e\u5e2e\u5fd9\uff01\u8bf7\u6559\u4e2a SQL \u4e0d\u77e5\u9053\u548b\u5199\u3002\u3002\u3002               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dtgxx <\/span>  <span><i><\/i> 13<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>CREATE TABLE <code>num_t<\/code> ( <code>num<\/code> varchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8<\/p>\n<p>CREATE TABLE <code>range_t<\/code> ( <code>maxn<\/code> varchar(255) DEFAULT NULL, <code>minn<\/code> varchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8<\/p>\n<p>\u683c\u5f0f\u53d8\u5f97\u6709\u70b9\u96be\u770b\u3002\u3002\u89c1\u8c05\u3002\u3002\u6211\u60f3\u751f\u6210\u4e00\u5f20\u65b0\u8868\uff0c\u8868\u7ed3\u6784\u662f\u8fd9\u4e24\u4e2a\u7efc\u5408\u5728\u4e00\u8d77\u7684\uff0c\u6570\u636e\u8981\u6c42\u5c31\u662f num \u5728 maxn \u548c minn \u7684\u8303\u56f4\u5185\u3002<\/p>\n<p>select b.maxn,b.minn from (select num from num_t) a join (select maxn,minn from range_t) b on cast(a.num as signed)&gt;=cast(b.minn as signed) and cast(a.num as signed)&lt;=cast(b.maxn as signed);<\/p>\n<p>\u6211\u7684\u8fd9\u4e2a sql \u6267\u884c\u7ed3\u679c\u662f\u7a7a\uff0c\u4f30\u8ba1\u662f\u56e0\u4e3a on \u540e\u9762\u7684\u4e0d\u7b49\u503c\u8fde\u63a5\u95ee\u9898\u3002\u3002\u3002\u5927\u4f6c\u4eec\u6709\u6ca1\u6709\u597d\u7684\u529e\u6cd5\u53ef\u4ee5\u5b8c\u6210\u6211\u60f3\u8981\u7684\u8868\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>2<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4519740\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : keepeye <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6ca1\u6709\u5916\u952e\uff1f\u90a3\u53ea\u80fd\u6839\u636e id \u6765\u5457\uff0cnum_t t1 inner join range_t t2 on t1.id = t2.id where t1.num between t2.maxn and t2.minn <br \/>\u8fd9\u6837\u4e0d\u77e5\u9053\u662f\u4e0d\u662f\u4f60\u8981\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4519741\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : shijia <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &#8220;`sql<br \/>select * from num_t, range_t<br \/>where num_t.nm&gt;=range_t.minn<br \/> and num_t.nm&lt;=range_t.maxn<br \/>&#8220;`<br \/>\u9171\u7d2b\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u4f6c\u4eec\u6765\u5e2e\u5e2e\u5fd9\uff01\u8bf7\u6559\u4e2a SQL \u4e0d&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/230925"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=230925"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/230925\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=230925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=230925"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=230925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}