I am trying to use multiple inserts (in one statement) and I have this table structure
CREATE TABLE Scores
(
studentID varchar(50) not null,
score int
)
ENGINE = InnoDB
My Query:
INSERT INTO Scores Values
('Barry', 45),
(NULL, 41),
('Jones', 53)
This statement (I expected) should fail since [StudentID] column does not accept NULL. The problem was MySQL inserted empty string ('') into row 2... and allow the rest to continue.
Issue:
SET SQL_MODE='STRICT_ALL_TABLES'
or put
SQL_MODE='STRICT_ALL_TABLES'
under [mysqld]
into my.cnf
(then restart MySQL
).
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