mysql - Delete duplicate rows if two variables match PHP -


i have 2 variables $faceplateinstalled , $faceplateexists , print them 2 columns

faceplate exists    faceplate instaled   1                           1    1                           0    1                           1    0                           0    1                           1    1                           0    1                           1    1                           1    0                           0    0                           0    1                           0  

is there way remove entries have 1 , 1 in same row?

this query use:

"select f.id faceplateid, pr.premiseid, composeaddressfrompaf( pr.postaddressid ) fulladdress, " .             "   if( f.id not null, 1, 0 ) faceplateexists, " .             "   ifnull( f.installed, 0 ) faceplateinstalled, " .             "   pr.siteid, s.name sitename " .             "from ho_crm_premise pr " .             "   left join ho_faceplate f on f.premiseid = pr.premiseid " .             "   inner join bcube_site s on s.siteid = pr.siteid " .             "where s.siteid"; 

and whole function

function getfaceplates( $siteid )     {         $ssql =             "select f.id faceplateid, pr.premiseid, composeaddressfrompaf( pr.postaddressid ) fulladdress, " .             "   if( f.id not null, 1, 0 ) faceplateexists, " .             "   ifnull( f.installed, 0 ) faceplateinstalled, " .             "   pr.siteid, s.name sitename " .             "from ho_crm_premise pr " .             "   left join ho_faceplate f on f.premiseid = pr.premiseid " .             "   inner join bcube_site s on s.siteid = pr.siteid " .             "where s.siteid";          if( $siteid )         {             $ssql .= "   , pr.siteid = " . $siteid . " ";         }          $presult = $this->executesql( $ssql );         return $presult;     }   $db = new databaseinfinity();  $action = $_request["action"];  //$action = "search"; // temporary $siteid = $_request["siteid"];  if( $action == "search" ) {     $faceplates = $db->getfaceplates( $siteid );      while( $faceplate = fetchobject( $faceplates ) )     {         $tpl->newblock( "faceplate");         $tpl->assign( "id", $faceplate->faceplateid );         $tpl->assign( "premiseid", $faceplate->premiseid  );         $tpl->assign( "address", $faceplate->fulladdress );         $tpl->assign( "siteid", $faceplate->siteid );         $tpl->assign( "sitename", $faceplate->sitename );         $tpl->assign( "fexists", $faceplate->faceplateexists );         $tpl->assign( "finstaled", $faceplate->faceplateinstalled );     } } 

per edited post, can change query , include condition faceplateexists <> faceplateinstalled in outer query desired result below

select * ( select f.id faceplateid, pr.premiseid,  composeaddressfrompaf( pr.postaddressid ) fulladdress, " .             "   if( f.id not null, 1, 0 ) faceplateexists, " .             "   ifnull( f.installed, 0 ) faceplateinstalled, " .             "   pr.siteid, s.name sitename " .             "from ho_crm_premise pr " .             "   left join ho_faceplate f on f.premiseid = pr.premiseid " .             "   inner join bcube_site s on s.siteid = pr.siteid " .             "where s.siteid ) xxx faceplateexists <> faceplateinstalled; 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -