php - Make a query that only shows rows that has no null values -


i'm trying create query statement grab rows consist of no null values in columns. i'm not sure how go it.

here query statement:

    $query = "select scrap_wafers.lot, scrap_wafers.wafer_cell, scrap_wafers.flow, ". "scrap_wafers.route, scrap_wafers.scrap_date, scrap_wafers.scrap_comment, ". "scrap_type_names.scrap_tag_name, scrap_wafers.engineer, scrap_wafers.disposition_date, ". "scrap_wafers.disposition_comment, scrap_wafers.location, scrap_wafers.serial_sw, scrap_wafers.operator ". "from scrap_wafers ". "left join scrap_type_names on scrap_type_names.serial_stn = scrap_wafers.serial_stn ". "$cstring ". "group scrap_wafers.serial_sw ". "order scrap_wafers.scrap_date desc ". "limit $numrecs"; 

$criteria consists of:

$criteria = array(); if (!empty($lot)) {  $lotarray = explode(',', $lot);  $lot_criteria_str = "(";  foreach ($lotarray $lottmp) {   $lot_criteria_str = $lot_criteria_str . "scrap_wafers.lot '%$lottmp%' or ";  }   $lot_criteria_str = substr($lot_criteria_str,0,-3);   $lot_criteria_str = $lot_criteria_str . ")";  $criteria[] = $lot_criteria_str;  } if (!empty($wafer_cell)) {  $waferarray = explode(',', $wafer_cell);  $wafer_criteria_str = "(";  foreach ($waferarray $wafertmp) {   $wafer_criteria_str = $wafer_criteria_str . "scrap_wafers.wafer_cell '%$wafertmp%' or ";  }   $wafer_criteria_str = substr($wafer_criteria_str,0,-3);   $wafer_criteria_str = $wafer_criteria_str . ")";  $criteria[] = $wafer_criteria_str;  }      if (!empty($serial_flow)) $criteria[] = "scrap_wafers.serial_flow = '$serial_flow'";     if (!empty($serial_route)) $criteria[] = "scrap_wafers.serial_route = '$serial_route'";      if (!empty($operator)) $criteria[] = "scrap_wafers.operator = '$operator'";          if (!empty($serial_stn)) $criteria[] = "scrap_wafers.serial_stn = '$scrap_tag_name'";                    if (!empty($scrap_date)) $criteria[] = "scrap_wafers.scrap_date = '$scrap_date'";        if (!empty($serial_step)) $criteria[] = "scrap_wafers.serial_step = '$serial_step'";         if (!empty($location)) $criteria[] = "scrap_wafers.location = '$location'";                  if (!empty($completeness)) {         if ($completeness == 'default') {          // nothing         }         else if ($completeness == 'incomplete') {             $criteria[] = "scrap_wafers.disposition_date = null , scrap_wafers.engineer = null , ".             "scrap_wafers.disposition_comment = null , scrap_wafers.location = null ,  ".             "scrap_wafers.serial_stn = null";         }         else if ($completeness == 'complete') {             $criteria[] = "scrap_wafers.disposition_date = not null , scrap_wafers.engineer = not null , ".             "scrap_wafers.disposition_comment = not null , scrap_wafers.location = not null ,  ".             "scrap_wafers.serial_stn = not null";         }     }    $cstring = "";     if (count($criteria) > 0) {         $cstring = "where ".join(" , ", $criteria);     } else {         $cstring = "where 1=1 ";     } 

$completeness i'm trying filter either null values(incomplete) or no null values(complete).

you need use is null, not = null.

...  else if ($completeness == 'incomplete') {     $criteria[] = "scrap_wafers.disposition_date null , scrap_wafers.engineer null , ".     "scrap_wafers.disposition_comment null , scrap_wafers.location null ,  ".     "scrap_wafers.serial_stn null"; } else if ($completeness == 'complete') {     $criteria[] = "scrap_wafers.disposition_date not null , scrap_wafers.engineer not null , ".     "scrap_wafers.disposition_comment not null , scrap_wafers.location not null ,  ".     "scrap_wafers.serial_stn not null"; }  ... 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -