create table arts (
`id` int(11) auto_increment,
`name` varchar(255),
`source` varchar(255),
primary key (`id`)
) engine = innodb, charset utf8mb4 collate utf8mb4_croatian_ci;
insert into arts (name,source) values("lorem","lorem");
insert into arts (name,source) values("lorem","lorem");
insert into arts (name,source) values("lorem","lorem");
select * from arts where name = 0;
结果:
3
行为什么会这样?任何字段中都没有
0
值。 最佳答案
涉及到隐式转换:
select * from arts where name = '0'; => 0 rows (no implicit conversion)
select * from arts where name = 0; => 3 rows (varchar(255) -> INT)
db<>fiddle demo