- Does bool value false == 0 and true == 1
- Does Null value in varchar, int, date fields == 0?
- When by default in mysql values == 0 or NULL or empty string?
Does bool value false == 0 and true == 1 Does Null value in
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes – you can test using:
…it will return “false”, meaning zero indicates false and one indicates true. This example was taken from the MySQL documentation page.
No, NULL indicates the lack of any value at all.
You need to use special operators if you want to compare for the value being NULL.
Without default constraints in place, columns that allow NULL will contain NULL if no value has been provided — regardless of data type (DATETIME, numeric, text, etc). Columns that do not allow NULL will return an error until a value is provided that matches the data type of the column. Default constraints allow you to specify a default value if someone attempts to insert a NULL value into the column, or the column has been omitted from an INSERT statement.