{"id":696,"date":"2021-07-16T18:16:35","date_gmt":"2021-07-16T10:16:35","guid":{"rendered":"https:\/\/fireinsect.top\/?p=696"},"modified":"2021-07-23T12:39:44","modified_gmt":"2021-07-23T04:39:44","slug":"%e6%95%b0%e6%8d%ae%e5%ba%93%e5%9f%ba%e7%a1%80%e2%85%a1","status":"publish","type":"post","link":"https:\/\/fireinsect.top\/index.php\/2021\/07\/16\/%e6%95%b0%e6%8d%ae%e5%ba%93%e5%9f%ba%e7%a1%80%e2%85%a1\/","title":{"rendered":"\u6570\u636e\u5e93\u57fa\u7840\u2161"},"content":{"rendered":"\n<p class=\"has-large-font-size\">LIKE\u6a21\u7cca\u67e5\u8be2<\/p>\n\n\n\n<p>\u4e4b\u524d\u6211\u4eec\u5b66\u4e60\u7684\u67e5\u8be2\u8bed\u53e5\u90fd\u662f\u7cbe\u51c6\u67e5\u8be2\uff0c\u6211\u4eec\u90fd\u7528\u8fc7\u641c\u7d22\u5f15\u64ce\uff0c\u5728\u641c\u7d22\u5f15\u64ce\u4e2d\u6211\u4eec\u4f7f\u7528\u66f4\u591a\u7684\u662f\u6a21\u7cca\u67e5<br>\u8be2\uff0cSQL\u8bed\u53e5\u4e2d\u7684LIKE\u5b50\u53e5\u53ef\u4ee5\u8fbe\u5230\u7c7b\u4f3c\u7684\u6a21\u7cca\u67e5\u8be2\u7684\u6548\u679c\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u7ed3\u6784\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> table_name <strong>WHERE<\/strong> <strong>condition<\/strong> <strong>LIKE<\/strong> <strong>condition<\/strong>;<\/code><\/pre>\n\n\n\n<p>SQL LIKE \u5b50\u53e5\u4e2d\uff0c\u6211\u4eec\u7684\u4f7f\u7528\u767e\u5206\u53f7 %\u5b57\u7b26\u6765\u8868\u793a\u4efb\u610f\u5b57\u7b26\uff0c\u5982\u679c\u6211\u4eec\u6ca1\u6709\u4f7f\u7528\u4efb\u4f55\u7684%\uff0c\u90a3\u6b64\u65f6<br>LIKE\u5c31\u76f8\u5f53\u4e8e =<\/p>\n\n\n\n<p>\u6bd4\u5982\u6211\u4eec\u67e5\u627e\u540d\u5b57\u5e26\u5b59\u7684\u4eba<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong>\n  *\n<strong>FROM<\/strong>\n  people\n<strong>WHERE<\/strong>\n  name <strong>LIKE<\/strong> '%\u5b59%';<\/code><\/pre>\n\n\n\n<p><strong><span class=\"has-inline-color has-vivid-red-color\">%\u7684\u4f4d\u7f6e\u4f1a\u51b3\u5b9a\u641c\u7d22\u7ed3\u679c\u7684\u4e0d\u540c\uff0c&#8217;%\u5b59%&#8217;\u793a\u8fd9\u4e2a\u5b57\u7b26\u4e32\u542b\u5b59\uff0c&#8217;\u5b59%&#8217;\u8868\u793a\u8fd9\u4e2a\u5b57\u7b26\u4e32\u4ee5\u5b59\u5f00\u5934\uff0c&#8217;%\u5b59&#8217;\u8868<br>\u793a\u8fd9\u4e2a\u5b57\u7b26\u4e32\u4ee5\u5b59\u7ed3\u5c3e\u3002<\/span><\/strong><\/p>\n\n\n\n<p>\u9664\u4e86%\u7684\u6a21\u7cca\u67e5\u627e\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528  _   \u6765\u6a21\u7cca\u67e5\u627e<\/p>\n\n\n\n<p>\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong>\n  *\n<strong>FROM<\/strong>\n  timi_adc\n<strong>WHERE<\/strong>\n  hero_name <strong>LIKE<\/strong> '_\u5c1a\u9999';<\/code><\/pre>\n\n\n\n<p>\u4e0e % \u4e0d\u540c\u7684\u662f %\u53ef\u4ee5\u4ee3\u8868\u591a\u4e2a\u5b57\uff0c\u800c _ \u53ea\u80fd\u4ee3\u8868\u4e00\u4e2a\u5b57\uff0c\u5373 %\u5c1a\u9999 \u53ef\u4ee5\u67e5\u627e\u51fa \u516c\u5b59\u5c1a\u9999\uff0c\u800c _\u5c1a\u9999 \u4e0d\u80fd<\/p>\n\n\n\n<p class=\"has-large-font-size\">AND\u548cOR<\/p>\n\n\n\n<p>\u4e4b\u524d\u6211\u4eec\u5199\u7684 WHERE \u8bed\u53e5\u90fd\u662f\u53ea\u6709\u4e00\u4e2a\u6761\u4ef6\u7684\uff0c\u5728\u5b9e\u9645\u751f\u6d3b\u4e2d\uff0c\u6211\u4eec\u5f80\u5f80\u4f1a\u4f7f\u7528\u591a\u4e2a\u6761\u4ef6\uff0c\u8fd9\u4e2a\u65f6<br>\u5019\u5c31\u9700\u8981\u4f7f\u7528 AND \u548c OR \u5173\u952e\u8bcd\u3002<\/p>\n\n\n\n<p>\u7ed3\u6784\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> table_name <strong>WHERE<\/strong> conditionA <strong>AND<\/strong>\/<strong>OR<\/strong> condtionB;<\/code><\/pre>\n\n\n\n<p>\u6bd4\u5982\u6211\u4eec\u8981\u67e5\u8be2 timi_adc \u8868\u4e2d\u80dc\u7387\u4e3a\u767e\u5206\u4e4b 50%-51%\u6216\u8005\u80dc\u7387\u4f4e\u4e8e 47%\u7684\u82f1\u96c4\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u8fd9\u4e48<br>\u5199 SQL\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong>\n  *\n<strong>FROM<\/strong>\n  timi_adc\n<strong>WHERE<\/strong>\n  win_rate &gt; 0.5\n  <strong>AND<\/strong> win_rate &lt; 0.51\n  <strong>OR<\/strong> win_rate &lt; 0.47;<\/code><\/pre>\n\n\n\n<p>\u540c\u65f6\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528  \uff08\uff09 \u6765\u5206\u5272\u903b\u8f91\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong>\n  *\n<strong>FROM<\/strong>\n  timi_adc\n<strong>WHERE<\/strong>\n  win_rate &gt; 0.5\n  <strong>OR<\/strong> (\n    win_rate &lt; 0.47\n    <strong>AND<\/strong> win_rate &lt; 0.51\n  );<\/code><\/pre>\n\n\n\n<p class=\"has-large-font-size\">IN\/NOT IN<\/p>\n\n\n\n<p>\u6211\u4eec\u4f7f\u7528\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> table_name <strong>WHERE<\/strong> <strong>column<\/strong> <strong>IN<\/strong> (condtionA,condtionB);<\/code><\/pre>\n\n\n\n<p>\u5982<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong>\n  *\n<strong>FROM<\/strong>\n  timi_adc\n<strong>WHERE<\/strong>\n  fever <strong>IN<\/strong> ('T0', 'T3');<\/code><\/pre>\n\n\n\n<p>\u7b49\u4ef7\u4e8e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong>\n  *\n<strong>FROM<\/strong>\n  timi_adc\n<strong>WHERE<\/strong>\n  fever = 'T0'\n  <strong>OR<\/strong> fever = 'T3';<\/code><\/pre>\n\n\n\n<p>\u5728IN\u524d\u52a0\u4e0aNOT\u8868\u793a\u975e\uff0c\u5373\u9664\u53bb\u6240\u9009\u6761\u4ef6\u5982<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong>\n  *\n<strong>FROM<\/strong>\n  timi_adc\n<strong>WHERE<\/strong>\n  fever <strong>NOT<\/strong> <strong>IN<\/strong> ('T0');<\/code><\/pre>\n\n\n\n<p>\u5373\u67e5\u8be2\u65f6\u9664\u53bbfever\u4e3aT0\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<p>LIKE\u4e5f\u53ef\u4ee5\u52a0\u4e0aNOT \u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong>\n  *\n<strong>FROM<\/strong>\n  timi_adc\n<strong>WHERE<\/strong>\n  hero_name <strong>NOT<\/strong> <strong>LIKE<\/strong> '%\u5b59%';<\/code><\/pre>\n\n\n\n<p>\u6548\u679c\u4e0eNOT IN \u7c7b\u4f3c\uff0c\u4e0d\u8fc7IN\u662f\u7cbe\u786e\u67e5\u8be2\uff0cLIKE\u662f\u6a21\u7cca\u67e5\u8be2\u3002<\/p>\n\n\n\n<p class=\"has-large-font-size\">NULL\u503c\u5904\u7406<\/p>\n\n\n\n<p>\u6211\u4eec\u5728\u4e4b\u524d\u7684\u5b66\u4e60\u4e2d\u6709\u6d89\u53ca\u5230 NULL \u503c\uff0cNULL \u5bf9\u5e94\u7684\u662f NOT NULL ,\u5b83\u4eec\u662f MySQL \u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\u7684<br>\u5c5e\u6027\uff0cNULL \u672c\u8eab\u4e0d\u5c5e\u4e8e\u4efb\u4f55\u6570\u636e\u7c7b\u578b\uff0c NULL \u503c\u4e5f\u4e0d\u7b49\u4e8e\u7a7a\u503c\uff0c\u7a7a\u503c\u662f\u4e0d\u5360\u7528\u5b58\u50a8\u7a7a\u95f4\u7684\uff0cNULL \u5360\u7528\u5b58\u50a8<br>\u7a7a\u95f4\u3002<\/p>\n\n\n\n<p>MySQL \u4e3a\u5904\u7406 NULL \u503c\u63d0\u4f9b\u4e86\u4e09\u79cd\u8fd0\u7b97\u7b26\uff1a<\/p>\n\n\n\n<p> 1. IS NULL\uff1a\u5f53\u5217\u7684\u503c\u662f NULL \u65f6\uff0c\u8fd9\u4e2a\u8fd0\u7b97\u7b26\u8fd4\u56de true<\/p>\n\n\n\n<p> 2. IS NOT NULL\uff1a\u5f53\u5217\u7684\u503c\u4e0d\u4e3a NULL\uff0c\u8fd9\u4e2a\u8fd0\u7b97\u7b26\u8fd4\u56de true <\/p>\n\n\n\n<p>3. &lt;=>\uff1a\u6bd4\u8f83\u64cd\u4f5c\u7b26\uff0c\u5f53\u6bd4\u8f83\u7684\u4e24\u4e2a\u503c\u90fd\u4e3a NULL \u65f6\u6216\u8005\u76f8\u7b49\u65f6\uff0c\u8fd4\u56de\u4e3a true<\/p>\n\n\n\n<p>\u6ce8\u610f\uff1a\u6211\u4eec\u4e0d\u80fd\u4f7f\u7528=NULL \u6216\u8005\uff01=NULL \u6765\u67e5\u627e NULL \u503c \uff0cNULL = NULL \u4f1a\u8fd4\u56de NULL<\/p>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> field_name1,field_name2\n<strong>FROM<\/strong> table_name\n<strong>WHERE<\/strong> field_name2 <strong>IS<\/strong> <strong>NOT<\/strong> <strong>NULL<\/strong>\/<strong>IS<\/strong> <strong>NULL<\/strong>;<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>LIKE\u6a21\u7cca\u67e5\u8be2 \u4e4b\u524d\u6211\u4eec\u5b66\u4e60\u7684\u67e5\u8be2\u8bed\u53e5\u90fd\u662f\u7cbe\u51c6\u67e5\u8be2\uff0c\u6211\u4eec\u90fd\u7528\u8fc7\u641c\u7d22\u5f15\u64ce\uff0c\u5728\u641c\u7d22\u5f15\u64ce\u4e2d\u6211\u4eec\u4f7f\u7528\u66f4\u591a\u7684\u662f\u6a21\u7cca\u67e5\u8be2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[6,1],"tags":[],"class_list":["post-696","post","type-post","status-publish","format-standard","hentry","category-6","category-wcd"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts\/696"}],"collection":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/comments?post=696"}],"version-history":[{"count":7,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts\/696\/revisions"}],"predecessor-version":[{"id":704,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts\/696\/revisions\/704"}],"wp:attachment":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/media?parent=696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/categories?post=696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/tags?post=696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}