{"id":4479,"date":"2023-03-09T10:19:59","date_gmt":"2023-03-09T10:19:59","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=4479"},"modified":"2023-06-16T15:44:26","modified_gmt":"2023-06-16T14:44:26","slug":"in-is-value-in-a-list-of-values","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/mysql\/queries\/select\/in-is-value-in-a-list-of-values","title":{"rendered":"IN &#8211; is value IN a list of values"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>value IN (value1, value2, value3,...)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Using IN operator<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\"SELECT * FROM MyTableName WHERE MyColumnName IN (12, 16, 22)\"<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Example using an array<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>  $sql = \"SELECT * FROM MyTableName WHERE MyColumnName IN ( \";  \r\n  $NotFirst = False;\r\n  foreach ($MyArray as $MyArrayItem)\r\n  {\r\n    if ($NotFirst)\r\n      $sql .= \",\";\r\n    $sql .= $wpdb->prepare(\"%d\", $MyArrayItem);\r\n    \r\n    $NotFirst = True;\r\n  }\r\n  $sql .= \" )\";<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Using IN operator Example using an array<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[],"class_list":["post-4479","post","type-post","status-publish","format-standard","hentry","category-select"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4479","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=4479"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4479\/revisions"}],"predecessor-version":[{"id":4515,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4479\/revisions\/4515"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=4479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=4479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=4479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}