我的 SQL 代码
$sqlNull = "SELECT primary_maths ,primary_enviornment ,primary_english
,primary_sinhala ,primary_tamil ,p_special_english ,p_a ,p_b ,p_c ,p_d ,p_e
,p_f ,p_g ,ol_maths ,ol_maths_paperClass ,ol_english ,ol_sinhala ,ol_tamil
,ol_science ,ol_history ,ol_commerce ,ol_art ,al_class_chemesty
,al_class_physics ,al_class_combindmaths ,al_class_bioscience ,al_class_economics
,al_class_businessStudies ,al_class_account ,al_class_sinhala
,al_class_logic ,al_class_buddhist ,scouting ,sp_eng ,rev_a
,rev_b ,rev_c ,rev_d ,rev_e ,rev_f ,rev_g ,rev_h ,rev_i ,rev_j
,o_a ,o_b ,o_c ,o_d ,o_e ,o_f ,o_g ,o_h ,o_i ,o_j
FROM Persons WHERE reg_id='$search' IS NOT NULL";
我的 PHP 代码
$sqlSubject=$dbconnect->prepare($sqlNull);
$sqlSubject->execute();
$resultFull=$sqlSubject->fetchALL(PDO::FETCH_ASSOC);
var_dump($resultFull);
现在我的输出是
array (size=0)
empty
如何将WHERE 子句与参数和IS NOT NULL一起使用。我有 59 列,其中一些包含NULL值。所以我想在输出($resultFull)来自数据库时删除它们。换句话说,我想选择值在哪里不为空