mysql查询检查多个非空列

时间:2016-07-15 07:21:34

标签: php mysql

我想检查多个非空列,就像我检查多个空列一样: -

SELECT * FROM users WHERE "" IN(`profilepic2`,`bsector`,`gender`,`first_name`,`sur_name`,`phone`,`hphone`,`countryresd`,`passportnum`,`maritalstatus`,`haddress`,`countryofbus`,`maddress`,`paddress`)

现在我不希望通过mysql查询清空列。

3 个答案:

答案 0 :(得分:1)

这应该是有效的。用您需要的列替换some_col

 SELECT * FROM users WHERE some_col IS NULL OR some_col = " ";

答案 1 :(得分:0)

SELECT * FROM users WHERE some_col!="" AND some_col IS NOT NULL;

答案 2 :(得分:0)

$fields = mysql_query("SHOW columns FROM mytablename");
while($row = mysql_fetch_array($fields))
{$field_name[] = $row['Field'];
}
for($i=0; $i<sizeof($field_name; $i++;)){`enter code here`
"SELECT * FROM users WHERE '".$field_name[$i]."' IS NULL OR '".$field_name[$i]."' = ''";
}