Whenever I do a SELECT
statement with WHERE id is NULL
directly after an INSERT
, I get the last inserted row.
I am using MySQL 5.1.73.
It happens directly in the MySQL shell; here is my console:
mysql> CREATE TABLE testing (
-> id int(11) NOT NULL AUTO_INCREMENT,
-> name VARCHAR(200),
-> PRIMARY KEY (id)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.03 sec)
mysql> INSERT INTO testing (name) VALUES ('test');
Query OK, 1 row affected (0.01 sec)
mysql> SELECT * FROM testing WHERE id IS NULL;
+----+------+
| id | name |
+----+------+
| 1 | test |
+----+------+
1 row in set (0.01 sec)
Can anyone tell me what's going on here? Is this a bug or is it a setting I am missing?