title: How can i make this mysqli query run faster in PHP?
body: <p>$networks is the string with multiple values seperated with Commas.
  Example : </p>
  
  <pre><code>$networks = "Programming,Movies,Hollywood". (There can be around 150 values or more.)    
  </code></pre>
  
  <p>Now the Mysql query goes here :<br></p>
  
  <pre><code>$query = "SELECT * FROM table 
            WHERE ( isActive = 1 AND 
                    isDeleted = 0 AND 
                    onid = '0' AND 
                    question = 0 AND 
                    ( ".$networkqur." )
                  ) 
  ORDER BY id DESC
  LIMIT 0,100;
  </code></pre>
  
  <p>Here $networkqur is :</p>
  
  <pre><code>$network = explode(',',$networks);
  
  $networkqur = '';
  for( $i = 0; $i &lt; count($network); $i++ ){
      $networkqur .= 'networks LIKE "%'.$network[$i].'%"';
      if( $i != count($network) - 1 ){
          $networkqur .= ' OR ';
      }
  }
  </code></pre>
  
  <p>So effectively $networkqur becomes :</p>
  
  <pre><code>$networkqur = "networks LIKE "%Programming%" OR 
                 networks LIKE "%Movies%" OR 
                 networks LIKE "%Hollywood%";
  </code></pre>
  
  <p>And the Effective Query Becomes : </p>
  
  <pre><code>$query = "SELECT * FROM posts
            WHERE ( isActive = 1 AND 
                    isDeleted = 0 AND 
                    onid = '0' AND 
                    question = 0 AND 
                     ( networks LIKE "%Programming%" OR 
                       networks LIKE "%Movies%" OR 
                       networks LIKE "%Hollywood% ) 
                     ) 
            ORDER BY id DESC
            LIMIT 0,100;
  </code></pre>
  
  <p>Now as we can see there can be 150 OR Conditionals in the query and multiple AND conditionals with Sorting at the end. <br>
  Can there be any replacement of this particular query or any other faster way to execute it?</p>