{"id":128888,"date":"2022-08-01T19:49:18","date_gmt":"2022-08-01T13:49:18","guid":{"rendered":"http:\/\/rcl-radio.ru\/?p=128888"},"modified":"2022-08-01T19:49:18","modified_gmt":"2022-08-01T13:49:18","slug":"mysql-%d1%81%d1%80%d0%b0%d0%b2%d0%bd%d0%b5%d0%bd%d0%b8%d0%b5-%d1%81-%d0%bc%d0%b0%d1%81%d1%81%d0%b8%d0%b2%d0%be%d0%bc-in-not-in","status":"publish","type":"post","link":"http:\/\/rcl-radio.ru\/?p=128888","title":{"rendered":"mysql &#8212; \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c (IN, NOT IN)"},"content":{"rendered":"<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043a \u0431\u0430\u0437\u0435 mysql \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c:<\/p>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 10px;\">$query = <span style=\"color: #ff0000;\">\"SELECT * FROM table WHERE name IN ('book', 'painting, 'drawing')\"<\/span>;\r\n$result = mysqli_query<span style=\"color: #66cc66;\">(<\/span>$connect,$query<span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #b1b100;\">while<\/span><span style=\"color: #66cc66;\">(<\/span>$r = mysqli_fetch_array<span style=\"color: #66cc66;\">(<\/span>$result<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>...<span style=\"color: #66cc66;\">}<\/span><\/pre>\n<p>\u0412 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b <strong>table<\/strong>, \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 <strong>name<\/strong> \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 <strong>&#8216;book&#8217;, &#8216;painting, &#8216;drawing&#8217;<\/strong>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0412\u0430\u0441 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 mysql \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 10px;\">$query = <span style=\"color: #ff0000;\">\"SELECT * FROM table WHERE name IN (\"<\/span>.<span style=\"color: #006600;\">implode<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">','<\/span>, $arr<span style=\"color: #66cc66;\">)<\/span>.<span style=\"color: #ff0000;\">\")\"<\/span>;\r\n$result = mysqli_query<span style=\"color: #66cc66;\">(<\/span>$connect,$query<span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #b1b100;\">while<\/span><span style=\"color: #66cc66;\">(<\/span>$r = mysqli_fetch_array<span style=\"color: #66cc66;\">(<\/span>$result<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>...<span style=\"color: #66cc66;\">}<\/span><\/pre>\n<p>\u0412 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b <strong>table<\/strong>, \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 <strong>name<\/strong> \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <strong>$arr.<\/strong><\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0412\u0430\u043c \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u0440\u043e\u043c\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435, \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 10px;\">$query = <span style=\"color: #ff0000;\">\"SELECT * FROM table WHERE name NOT IN (\"<\/span>.<span style=\"color: #006600;\">implode<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">','<\/span>, $arr<span style=\"color: #66cc66;\">)<\/span>.<span style=\"color: #ff0000;\">\")\"<\/span>;\r\n$result = mysqli_query<span style=\"color: #66cc66;\">(<\/span>$connect,$query<span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #b1b100;\">while<\/span><span style=\"color: #66cc66;\">(<\/span>$r = mysqli_fetch_array<span style=\"color: #66cc66;\">(<\/span>$result<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>...<span style=\"color: #66cc66;\">}<\/span><\/pre>\n<p>\u0412 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b <strong>table<\/strong>\u00a0\u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 <strong>name, <\/strong>\u043a\u0440\u043e\u043c\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435\u00a0<strong>$arr.<\/strong><\/p>\n<hr \/>\n<p><strong><span class=\"refname\">implode<\/span><\/strong>\u00a0\u2014\u00a0<span class=\"dc-title\">\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043a \u0431\u0430\u0437\u0435 mysql \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c: $query = &#171;SELECT * FROM table WHERE name IN (&#8216;book&#8217;, &#8216;painting, &#8216;drawing&#8217;)&#187;; $result = mysqli_query($connect,$query); while($r = mysqli_fetch_array($result)){&#8230;} \u0412 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b table, \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 name \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 &#8216;book&#8217;, &#8216;painting, &#8216;drawing&#8217;. \u0415\u0441\u043b\u0438 \u0443 \u0412\u0430\u0441 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":128889,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[183],"tags":[],"class_list":["post-128888","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"views":2267,"_links":{"self":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/128888","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=128888"}],"version-history":[{"count":1,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/128888\/revisions"}],"predecessor-version":[{"id":128890,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/128888\/revisions\/128890"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/media\/128889"}],"wp:attachment":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=128888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=128888"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=128888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}