{"id":85387,"date":"2020-05-15T21:17:59","date_gmt":"2020-05-15T13:17:59","guid":{"rendered":"http:\/\/4563.org\/?p=85387"},"modified":"2020-05-15T21:17:59","modified_gmt":"2020-05-15T13:17:59","slug":"%e8%af%b7%e6%95%99%e4%b8%80%e4%b8%8b%ef%bc%8c%e8%bf%99%e7%a7%8d-sql-%e6%80%8e%e4%b9%88%e5%86%99","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=85387","title":{"rendered":"\u8bf7\u6559\u4e00\u4e0b\uff0c\u8fd9\u79cd sql \u600e\u4e48\u5199"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559\u4e00\u4e0b\uff0c\u8fd9\u79cd sql \u600e\u4e48\u5199               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : NoKey <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6570\u636e\u5e93\u662f oracle<\/p>\n<p>\u6211\u4ece\u4e00\u4e2a\u8868\u91cc\u67e5\u5904\u7684\u6570\u636e\u7c7b\u4f3c\u4e8e 1,2,3<\/p>\n<p>\u7136\u540e\uff0c\u8fd9\u4e2a\u662f\u53e6\u5916\u4e00\u4e2a\u6570\u636e\u8868\u7684 id\uff0c\u6211\u60f3\u628a\u8fd9\u4e2a\u7ed3\u679c\u653e\u5230 in \u91cc\u9762\uff0c\u8fd9\u6837\u67e5\u51fa id \u5bf9\u5e94\u7684\u6570\u636e\u4fe1\u606f\u3002<\/p>\n<p>\u5927\u6982\u5c31\u662f select * from a where id in (select ids from b)<\/p>\n<p>\u4f46\u662f\u6211\u4e0d\u77e5\u9053\u600e\u4e48\u628a\u7ed3\u679c\u653e\u5230 in \u91cc<\/p>\n<p>\u6c42\u5927\u4f6c\u6307\u6559\uff0c\u8c22\u8c22\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>13<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1554853\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : getui163 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8fd9\u4e2a 1,2,3 \u5982\u679c\u662f\u591a\u884c\u7684\uff0c\u4f60\u8fd9\u4e2a\u5199\u6cd5\u5b8c\u5168 OK \u554a<br \/>\u6216\u8005 join \u4e5f\u884c<\/p>\n<p>\u5982\u679c\u8fd9\u4e2a\u6570\u636e\u662f\u5355\u884c\u7684\u67d0\u5217\uff0c\u60f3\u6309\u9017\u53f7\u62c6\u5206\uff0c\u770b\u4e0b REGEXP_SUBSTR \u8fd9\u4e2a\u51fd\u6570                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1554854\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : RSDTE <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             SELECT * FROM a c WHERE EXISTS( SELECT id FROM b o WHERE o.id=c.id) <\/p>\n<p>\u8fd9\u4e2a\u610f\u601d?                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1554855\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : liuhuan475 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u591a\u5217\uff1f\u7528 union all                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1554856\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Johnny168 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u662f\u60f3\u628a\u6570\u636e\u5b57\u6bb5\uff08 1\uff0c2\uff0c3 \uff09\uff0c\u62c6\u6210&#8217;1&#8242;,&#8217;2&#8242;,&#8217;3&#8242; \u4e09\u4e2a ID \u7684\u610f\u601d\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1554857\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xuanbg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3b\u7684\u610f\u601d\u5927\u6982\u662f A \u8868\u7684\u67d0\u4e9b id \u5b58\u5728 B \u8868\u7684\u67d0\u4e2a\u5b57\u6bb5\uff0c\u4ee5\u9017\u53f7\u5206\u9694\u3002\u7136\u540e\u6839\u636e\u8fd9\u4e2a\u5b57\u6bb5\u67e5\u8be2 A \u8868\u7684\u8bb0\u5f55\u3002<\/p>\n<p>\u76f4\u63a5 in \u662f\u4e0d\u884c\u7684\uff0c\u8981\u7528\u51fd\u6570\u5904\u7406\u4e00\u4e0b\uff0c\u5177\u4f53\u7684\u505a\u6cd5\u53ef\u4ee5\u767e\u5ea6\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1554858\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : RJH <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             oracle \u6709\u4e2a FIND_IN_SET \u51fd\u6570\uff0c\u4f60\u53ef\u4ee5\u770b\u770b\u662f\u5426\u6ee1\u8db3\u4f60\u7684\u9700\u6c42                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1554859\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sh0214 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u628a b \u8868\u7684\u7ed3\u679c\u7528\u5b57\u6bb5\u5b58\u8d77\u6765\u7136\u540e\u505a\u62fc\u63a5\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1554860\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : c6h6benzene <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u65b0\u7684 SQL SERVER \u6709 split_string \u51fd\u6570                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1554861\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : NoKey <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @getui163 \u8c22\u8c22\uff0c\u5c31\u662f\u4e00\u4e2a\u5b57\u6bb5\uff0c\u91cc\u9762\u5b58\u7684\u662f 1\uff0c2\uff0c3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1554862\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : NoKey <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Johnny168 \u662f\u7684\uff0c\u67e5\u51fa\u6765\u662f 1\uff0c2\uff0c3 \u60f3\u76f4\u63a5\u653e\u5230 in \u91cc\u9762                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1554863\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : NoKey <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @xuanbg \u8c22\u8c22\uff0c\u662f\u8fd9\u4e2a\u610f\u601d\uff0c\u4e00\u4e2a\u5b57\u6bb5\u5c31\u662f 1\uff0c2\uff0c3 \u8fd9\u6837\u7684\u5b57\u7b26\u4e32                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1554864\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : PopRain <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u731c SQL SERVER \u53ef\u4ee5\u8fd9\u4e48\u5199<br \/>select * from a inner join b on (b.ids like a.id+&#8217;,%&#8217; or b.ids like &#8216;,&#8217;+a.id+&#8217;%&#8217;)<\/p>\n<p>id \u4e0d\u80fd\u53c8\u5305\u542b\u5173\u7cfb 1\uff0c11\uff0c111 \u4e0d\u884c                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1554865\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : CRVV <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u90fd\u7528\u4e0a oracle \u8fd9\u4e48\u9ad8\u7ea7\u7684\u6570\u636e\u5e93\u4e86\uff0c\u8bf7\u6b63\u7ecf\u5730\u8bbe\u8ba1\u4e00\u4e0b\u8868\u3002\u4e0d\u8981\u7528\u8fd9\u79cd\u5947\u602a\u7684\u65b9\u5f0f\u6765\u50a8\u5b58\u4e00\u5bf9\u591a\u6216\u8005\u591a\u5bf9\u591a\u7684\u6570\u636e\u3002<\/p>\n<p>\u4e00\u5b9a\u8981\u8fd9\u4e48\u67e5\u7684\u8bdd\uff0c\u7528 PostgreSQL \u662f\u8fd9\u4e48\u5199\u7684<br \/>with a(id, v) as (values (1,&#8217;a&#8217;), (2,&#8217;b&#8217;), (3,&#8217;c&#8217;)), b(id,ids) as (values (8, &#8216;1,3,4&#8217;), (9,&#8217;2,5,8&#8242;))<br \/>SELECT * from b<br \/>cross join regexp_split_to_table(ids, &#8216;,&#8217;) as aids(aid)<br \/>inner join a on a.id = aids.aid::int<br \/>where b.id = 8;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559\u4e00\u4e0b\uff0c\u8fd9\u79cd sql \u600e\u4e48\u5199 \u8cc7&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\/85387"}],"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=85387"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/85387\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85387"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}