MySQL table structure where the fields
my_date
DateTime DEFAULT NULL,
See a simple Insert code first
$sql = "INSERT into My_test (my_date) VALUES (')";
Mysqli_query ($DBC, $sql);
Insert failed How do I insert an empty string into mysql datetime or int?
Of course I also know $sql = "INSERT into My_test (my_date) VALUES (null)"; can be inserted successfully;
But the insert code is that my backup database (. sql) automatically generates an empty string instead of NULL if the datetime itself does not have data, then it cannot be inserted properly? Or how to output insert into My_test (my_date) VALUES (NULL) this null in. sql?
Experts online, such as!!!!!!!!!!!!!!
Reply content:
MySQL table structure where the fields are my_date
datetime DEFAULT NULL,
See a simple Insert code first
$sql = "INSERT into My_test (my_date) VALUES (')";
Mysqli_query ($DBC, $sql);
Insert failed How do I insert an empty string into mysql datetime or int?
Of course I also know $sql = "INSERT into My_test (my_date) VALUES (null)"; can be inserted successfully;
But the insert code is that my backup database (. sql) automatically generates an empty string instead of NULL if the datetime itself does not have data, then it cannot be inserted properly? Or how to output insert into My_test (my_date) VALUES (NULL) this null in. sql?
Experts online, such as!!!!!!!!!!!!!!
Sets the default string to null or directly executes SQL
a value that is set to empty
String can only be inserted in a type field such as varchar char text
int datatime can be null, but only if the field is designed to allow null
How do you lead the curiosity, NULL export SQL statement is empty string?
Can't answer you, must not be.
You have a problem when you back up, NULL is NULL, can not become ", or use the normal way to import export data, such as the mysqldump command, or through phpMyAdmin, Navicat for MySQL and other tools.