title: NOT LIKE does not work with JOIN in wordpress
body: <p>I have this sql query in wordpress with php</p>
  <pre><code>        $sql = &quot;SELECT last_update.post_id FROM {$wpdb-&gt;postmeta} last_update&quot;;
          $sql .= &quot; JOIN {$wpdb-&gt;posts} AS post ON last_update.post_id = post.ID&quot;;
  
          $sql .= $wpdb-&gt;prepare(&quot; WHERE {$time} - last_update.meta_value &gt; {$ttl} AND last_update.meta_key = %s&quot;, Importer::META_LAST_UPDATE);
          
  
  
          if (SyncConfig::getInstance()-&gt;option('published_only'))
              $sql .= &quot; AND post.post_status = 'publish'&quot;;
  
          $sql .= $wpdb-&gt;prepare(&quot; ORDER BY last_update.meta_value ASC LIMIT %d&quot;, self::getProductLimit());
  
          $product_ids = $wpdb-&gt;get_col($sql);
  
          shuffle($product_ids);
          error_log(print_r( $product_ids, true ));
  </code></pre>
  <p>What I want is to skip the results with a &quot;NOT LIKE&quot; for the wildcard result &quot;Product data not found&quot;</p>
  <p>Normally I would do something like this</p>
  <pre><code>        $sql = &quot;SELECT last_update.post_id FROM {$wpdb-&gt;postmeta} last_update&quot;;
          $sql .= &quot; JOIN {$wpdb-&gt;posts} AS post ON last_update.post_id = post.ID&quot;;
          
          //QUITAR PRODUCTOS CON DATA NOT FOUND
          $sql .= &quot; JOIN {$wpdb-&gt;postmeta} AS _ety_product_info ON last_update.post_id = _ety_product_info.post_id&quot;;
  
  
          $sql .= $wpdb-&gt;prepare(&quot; WHERE {$time} - last_update.meta_value &gt; {$ttl} AND last_update.meta_key = %s&quot;, Importer::META_LAST_UPDATE);
          
          //QUITAR PRODUCTOS CON DATA NOT FOUND
          $sql .= &quot; AND _ety_product_info.meta_value NOT LIKE '%Product data not found%'&quot;;
  
  
          if (SyncConfig::getInstance()-&gt;option('published_only'))
              $sql .= &quot; AND post.post_status = 'publish'&quot;;
  
          $sql .= $wpdb-&gt;prepare(&quot; ORDER BY last_update.meta_value ASC LIMIT %d&quot;, self::getProductLimit());
  
          $product_ids = $wpdb-&gt;get_col($sql);
  
          shuffle($product_ids);
          error_log(print_r( $product_ids, true ));
  </code></pre>
  <p>But it gives wrong data.
  The strangest thing is that if I remove the &quot;NOT LIKE&quot; and just leave it on &quot;LIKE&quot; it works delivering the expected result if the &quot;_ety_product_info&quot; column contains the value &quot;Product data not found&quot;</p>
  <p>What am I doing wrong?
  I want to exclude with &quot;NOT LIKE&quot; but it doesn't work.</p>
  <p>Apparently this error only happens when I do the &quot;JOIN&quot;</p>
  <p>Note: To identify the changes made in the original code with the edited one, just search for: <code>//QUITAR PRODUCTOS CON DATA NOT FOUND</code></p>
  <p><strong>The final query</strong>
  <code>$sql</code> it would be this:</p>
  <pre><code>SELECT last_update.post_id
  FROM wp_postmeta last_update
  JOIN wp_posts AS post ON last_update.post_id = post.ID
  JOIN wp_postmeta AS _ety_product_info ON last_update.post_id = _ety_product_info.post_id
  WHERE 1659698743 - last_update.meta_value &gt; 86400
  AND last_update.meta_key = '_ety_last_update' 
  AND _ety_product_info.meta_value NOT LIKE '%Product data not found%' 
  AND post.post_status = 'publish' 
  ORDER BY last_update.meta_value ASC LIMIT 17
  </code></pre>
  <p>I also tried this but it didn't work.</p>
  <pre><code>$wild = '%';
  $find = 'Product data not found';
  $like = $wild . $wpdb-&gt;esc_like( $find ) . $wild;
  $sql .= $wpdb-&gt;prepare(&quot; AND _ety_product_info.meta_value NOT LIKE %s&quot;, $like);
  </code></pre>