当前位置:网站首页>Doubts about judging the tinyint field type of MySQL

Doubts about judging the tinyint field type of MySQL

2022-06-25 04:23:00 CSDN Q & A

In writing today SQL The sentence is ,where A... Is used in the condition tinyint Type field to judge , I didn't pay attention to the wrong judgment value , It's amazing that we can find the data
Here is the table and the corresponding SQL sentence
CREATE TABLE `test` (  `id` int(10) NOT NULL AUTO_INCREMENT COMMENT 'id',  `type` tinyint(4) NOT NULL COMMENT ' type ',  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT ' name ',  PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;INSERT INTO `test`(`id`, `type`, `name`) VALUES (1, 0, ' name 0');INSERT INTO `test`(`id`, `type`, `name`) VALUES (2, 1, ' name 1');INSERT INTO `test`(`id`, `type`, `name`) VALUES (3, 2, ' name 2');INSERT INTO `test`(`id`, `type`, `name`) VALUES (4, 0, ' name 4');
Perform the following two SQL sentence , The result is the same
select * from test where type = 'type ';select * from test where type = 0;
idtypename
10 name 0
40 name 4
I found a similar problem on the Internet , May I have your advice , What's the reason for this ?
原网站

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206181214194329.html