我的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 一起使用.I jsut有59列,其中一些包含 NULL 值。所以我想在输出($ resultFull)来自数据库时删除它们。换句话说,我想选择值 IS NOT NULL
答案 0 :(得分:0)
如果你想要一个查询结果,其中没有任何选定的cols为null,你必须改变你的WHERE,并为每个col添加“并且不为null”。就像Niels Keurentjes,Manish Jangir和Bailey S在上面写的那样。