Home >Backend Development >PHP Tutorial >mysql的char类型=0的判断

mysql的char类型=0的判断

WBOY
WBOYOriginal
2016-06-06 20:32:471829browse

mysql的表有一列的类型是char(3) default (0),select xx = 0为什么可以搜索出来所有的值?

回复内容:

mysql的表有一列的类型是char(3) default (0),select xx = 0为什么可以搜索出来所有的值?

收索条件如果是整数
那么mysql会吧字段的值先转成整数,然后再对比
如果字段的第一位是字符串,那么转成整数就是0了,
一般对字符串的收索都要加上引号
where xx = "131"

default(‘0’) 不是0 吧

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn