My table has an isSuccessful
column, I set the datatype as boolean (0 indicates false, 1 indicates true), and by default is 0.
But when I want to update this column using php,
UPDATE .......... SET isSuccessful = 1 WHERE .........
it doesn't work.
I tried to set the isSuccessful
as 1, true, yes, but none of them will work.
So how can I change the values of isSuccessful
?
MySQL UPDATE command can be used to update multiple columns by specifying a comma separated list of column_name = new_value. Where column_name is the name of the column to be updated and new_value is the new value with which the column will be updated.
MySQL does not have a boolean (or bool) data type. Instead, it converts boolean values into integer data types (TINYINT). When you create a table with a boolean data type, MySQL outputs data as 0, if false, and 1, if true.
MySQL does not contain built-in Boolean or Bool data type. They provide a TINYINT data type instead of Boolean or Bool data types. MySQL considered value zero as false and non-zero value as true. If you want to use Boolean literals, use true or false that always evaluates to 0 and 1 value.
A simple update query should suffice. Boolean fields are simply tinyint(1) fields and accept aliases for 1 and 0 as true and false respectively (as strings). The following should be fine. Perhaps if you posted your exact query rather than an abridged version someone might spot a problem?
UPDATE `table` SET `isSuccessful` = 1 WHERE `column` = 'criteria'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With