mysql where条件中int类型varchar类型默认值不同问题

 

model_id  int              default 0                 not null comment 'model id',

model_ids varchar(128)     default '0'               not null comment 'model id,逗号分割'

 上面两个字段在查询上有不同之处

where  model_id =''   这个条件 等同于  where model_id = 0;  //应该是mysql自动进行了转化

where model_ids ='' 这个条件  并不等同于 where model_ids='0'

另外 where model_id is null 与 where model_ids is null 都查询不到数据

因此在实际业务中如果设计到int类型的字段转化成varchar类型的字段要注意sql 条件中 默认值的处理

posted @ 2022-08-01 15:58  叫我林大官人  阅读(183)  评论(0)    收藏  举报