vendredi 2 février 2018

Did Long Query Containing With AND is good

As My question title i wants to ask that a bigger, very bigger query containing lots of AND Keyword is good. My query is as follow

SELECT * FROM `register` 
WHERE id != 0 
AND std = '1' 
AND city = '2' 
AND board = '2' 
AND school_name = '1' 
AND surname Like '%fdsg%'or middlename Like '%fdsg%'or lastname Like '%fdsg%' 
AND stay_alert_checkbox = '1' 
AND dmit_checkbox = '1' 
AND data_resorces = '2' 
AND datetime LIKE '%2018-02-07%' 
AND student_mobile = '9879879879' 
ORDER BY id DESC

This Works Fine Now on local server. query produce as user select filters i gave . so if user selects all filters this query is generate

And PHP Code is

if(!empty($standard)){
  $join .= " AND std = '".$standard."' ";
}

if(!empty($search_city)){
  $join .= " AND city = '".$search_city."' "; 
}

if (!empty($search_board)) {
  $join .= " AND board = '".$search_board."' "; 
}
AND SO ON.............

So is it good on server ?

Aucun commentaire:

Enregistrer un commentaire