Does a TINYINT value of 0 equal NULL when selecting from the cell? I though it would equal false. A little background: I am searching a table for selected checkboxes and then comparing that with posted php data: $sql = "SELECT username FROM candidate_details WHERE acca= '$_POST[acca]' OR msc_bp_mgmt = '$_POST[msc_bp_mgmt]'OR Code (markup): So I want the username pulled out if the cells match. If the checkbox on the form submitted was not selected, '$_POST[acca]' would be null. And then when i compare that to the candidate_details table cell, which has a value of '0' - (zero) - it is still coming up as a match? Is this right? Or is there another data type that actually enters TRUE or FALSE from a checkbox selection? help much appreciated Cheers
If you are referring to php, then yes 0 would evaluate as null. If you need to compare with a zero use === or !== instead of == and !=.
In a database, NULL means a field in which (for that record) no data has ever been entered. It's not the same as '' for a char field or 0 for a numeric field. If you enter '' in a char field or 0 in a numeric field it's not NULL.
NULL means empty, not even "0". "0" would be a digit, it might be a choice of "default" for example if featured item should be set to "1" then by default all items should be set to "0" or "2" 0 is just as good as "2" or any number because it can be used to identify the data. - Sumer Kolcak